Averages/Arithmetic mean: Difference between revisions

Content added Content deleted
m (H comes before J)
(-> IDL)
Line 80: Line 80:


mean xs = sum xs / Data.List.genericLength xs
mean xs = sum xs / Data.List.genericLength xs

=={{header|IDL}}==

If truly only the mean is wanted, one could use

x = [3,1,4,1,5,9]
print,mean(x)

But <tt>mean()</tt> is just a thin wrapper returning the zeroth element of <tt>moment()</tt> :

print,moment(x)
; ==>
3.83333 8.96667 0.580037 -1.25081

which are mean, variance, skewness and kurtosis.

There are no zero-length vectors in IDL. Every variable has at least one value or otherwise it is <tt><Undefined></tt>.



=={{header|J}}==
=={{header|J}}==