Averages/Pythagorean means: Difference between revisions

Added Quackery.
m (→‎{{header|Phix}}: simplified, added syntax colouring, marked p2js compatible)
(Added Quackery.)
Line 2,931:
 
These are the same in Python 2 apart from requiring explicit float division (either through <code>float()</code> casts or float literals such as <code>1./n</code>); or better, do a <code>from __future__ import division</code>, which works on Python 2.2+ as well as Python 3, and makes division work consistently like it does in Python 3.
 
=={{header|Quackery}}==
 
Uses <code>root</code> from [[Integer roots#Quackery]].
 
<lang Quackery> [] 10 times [ i^ 1+ join ]
 
say "Arithmetic mean:" sp
0 over witheach +
over size 8 point$ echo$
cr
say " Geometric mean:" sp
1 over witheach *
over size 80 ** * 10 root
10 8 ** 8 point$ echo$
cr
say " Harmonic mean:" sp
dup size dip
[ 0 n->v rot
witheach [ n->v 1/v v+ ] ]
n->v 2swap v/ 8 point$ echo$</lang>
 
{{out}}
 
<pre>Arithmetic mean: 5.5
Geometric mean: 4.52872868
Harmonic mean: 3.41417152
</pre>
 
=={{header|R}}==
1,462

edits