user
Task

Compute all three of the Pythagorean means of the set of integers 1 through 10 (inclusive).

Show that 

A
(

x

1
,
…
,

x

n
)
≥
G
(

x

1
,
…
,

x

n
)
≥
H
(

x

1
,
…
,

x

n
)
{\displaystyle {\displaystyle A(x\_{1},\ldots ,x\_{n})\geq G(x\_{1},\ldots ,x\_{n})\geq H(x\_{1},\ldots ,x\_{n})}}
 for this set of positive integers.

* The most common of the three means, the arithmetic mean, is the sum of the list divided by its length:

:   A
    (

    x

    1
    ,
    …
    ,

    x

    n
    )
    =

    x

    1
    +
    ⋯
    +

    x

    n
    n
    {\displaystyle {\displaystyle A(x\_{1},\ldots ,x\_{n})={\frac {x\_{1}+\cdots +x\_{n}}{n}}}}

* The geometric mean is the 

  n
  {\displaystyle {\displaystyle n}}
  th root of the product of the list:

:   G
    (

    x

    1
    ,
    …
    ,

    x

    n
    )
    =

    x

    1
    ⋯

    x

    n

    n
    {\displaystyle {\displaystyle G(x\_{1},\ldots ,x\_{n})={\sqrt[{n}]{x\_{1}\cdots x\_{n}}}}}

* The harmonic mean is 

  n
  {\displaystyle {\displaystyle n}}
   divided by the sum of the reciprocal of each item in the list:

:   H
    (

    x

    1
    ,
    …
    ,

    x

    n
    )
    =


    n

    1

    x

    1
    +
    ⋯
    +


    1

    x

    n
    {\displaystyle {\displaystyle H(x\_{1},\ldots ,x\_{n})={\frac {n}{{\frac {1}{x\_{1}}}+\cdots +{\frac {1}{x\_{n}}}}}}}

See also

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| | Tasks for calculating statistical measures | | | --- | --- | |  | | |  |  |  |  |  | | --- | --- | --- | --- | --- | |  | | in one go | moving *(sliding window)* | moving *(cumulative)* | | Mean | Arithmetic | Statistics/Basic  Averages/Arithmetic mean  Averages/Pythagorean means | Averages/Simple moving average |  | | Geometric | Averages/Pythagorean means |  |  | | Harmonic | Averages/Pythagorean means |  |  | | Quadratic | Averages/Root mean square |  |  | | Circular | Averages/Mean angle  Averages/Mean time of day |  |  | | Median | | Averages/Median |  |  | | Mode | | Averages/Mode |  |  | | Standard deviation | | Statistics/Basic |  | Cumulative standard deviation | | | |

---
assistant
(formerly Perl 6)

**Works with**: Rakudo version 2015.12

```
sub A { ([+] @_) / @_ }
sub G { ([*] @_) ** (1 / @_) }
sub H { @_ / [+] 1 X/ @_ }

say "A(1,...,10) = ", A(1..10);
say "G(1,...,10) = ", G(1..10);
say "H(1,...,10) = ", H(1..10);

```

Output:

```
A(1,...,10) = 5.5
G(1,...,10) = 4.52872868811677
H(1,...,10) = 3.41417152147406
```