Fork me on GitHub
Source file: means.fut

Means

The arithmetic mean of an array of f64 numbers can be computed as follows:

def mean [n] (vs: [n]f64) =
  f64.sum vs / f64.i64 n
> mean [1.0,2.0,3.0,4.0]
2.5f64

The geometric mean is likewise simple:

def gmean [n] (xs: [n]f64) =
  f64.product xs ** (1/f64.i64 n)
> gmean [1.0,2.0,3.0,4.0]
2.213363839400643f64

See also

Variance.

The statistics package.