Struct Mean

Output range to calculate the mean online. Getter for mean costs a branch to check for N == 0. This struct uses O(1) space and does *NOT* store the individual elements.

struct Mean ;

Properties

NameTypeDescription
mean[get] double
N[get] double
sum[get] double
toMean[get] MeanSimply returns this. Useful in generic programming contexts.

Methods

NameDescription
put
put Adds the contents of rhs to this instance.
toString

Note

This struct can implicitly convert to the value of the mean.

Examples

Mean summ;
summ.put(1);
summ.put(2);
summ.put(3);
summ.put(4);
summ.put(5);
assert(summ.mean == 3);