Task[edit]
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 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 A(x_{1},\ldots ,x_{n})={\frac {x_{1}+\cdots +x_{n}}{n}}}


 The geometric mean is the 



n


{\displaystyle n}

th root of the product of the list:
 



G
(

x

1


,
…
,

x

n


)
=




x

1


⋯

x

n




n





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


 The harmonic mean is 



n


{\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 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






/*REXX program  computes and displays the   Pythagorean means  [Amean,  Gmean,  Hmean]. */
numeric digits 20                                /*use a little extra for the precision.*/
parse arg n .                                    /*obtain the optional argument from CL.*/
if n=='' | n==","  then n= 10                    /*None specified?  Then use the default*/
sum= 0;  prod= 1;  rSum= 0                       /*initialize sum/product/reciprocal sum*/
$=;                       do #=1  for n;  $= $ # /*generate list by appending # to list.*/
                          sum = sum   +   #      /*compute the sum of all the elements. */
                          prod= prod  *   #      /*compute the product of all elements. */
                          rSum= rSum  + 1/#      /*compute the sum of the reciprocals.  */
                          end   /*#*/
say ' list ='$                                   /*display the list of numbers used.    */
say 'Amean ='  sum / n                           /*calculate & display  arithmetic mean.*/
say 'Gmean ='  Iroot(prod, n)                    /*    "     "     "    geometric    "  */
if result=="[n/a]"  then say '***error***: root' y "can't be even if 1st argument is < 0."
say 'Hmean ='  n   / rSum                        /*    "     "     "    harmonic     "  */
exit 0                                           /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Iroot: procedure; parse arg x 1 ox, y 1 oy       /*get both args, and also a copy of X&Y*/
       if x=0 | x=1 | y=1  then return x         /*handle special case of zero and unity*/
       if y=0              then return 1         /*   "      "      "   " a   zero root.*/
       if x<0 & y//2==0    then return  '[n/a]'  /*indicate result is "not applicable". */
       x= abs(x);          y= abs(y);   m= y - 1 /*use the absolute value for  X and Y. */
       oDigs= digits();    a= oDigs + 5          /*save original digits;  add five digs.*/
       g= (x+1) / y*2                            /*use this as the first guesstimate.   */
       d= 5                                      /*start with 5 dec digs, saves CPU time*/
           do  until d==a;      d= min(d + d, a) /*keep going as digits are increased.  */
           numeric digits d;    f= d - 2         /*limit digits to  original digits + 5.*/
           og=                                   /*use a non─guess for the old G (guess)*/
              do forever;       gm= g**m         /*keep computing at the   Yth   root.  */
              _= format( (m*g*gm + x)/(y*gm),,f) /*this is the nitty─gritty calculation.*/
              if _=g  |  _=og  then leave        /*are we close enough yet?             */
              og= g;            g= _             /*save guess ──► OG; set the new guess.*/
              end   /*forever*/
           end      /*until  */
 
       g= g * sign(ox);  if oy<0  then  g= 1 / g /*adjust for original X sign; neg. root*/
       numeric digits oDigs;      return   g / 1 /*normalize to original decimal digits.*/