Summary

Output range to compute mean, stdev, variance, skewness, kurtosis, min, and max online. Using this struct is relatively expensive, so if you just need mean and/or stdev, try MeanSD or Mean. Getter methods for stdev, var cost a few floating point ops. Getter for mean costs a single branch to check for N == 0. Getters for skewness and kurtosis cost a whole bunch of floating point ops. This struct uses O(1) space and does *NOT* store the individual elements.

Note: This struct can implicitly convert to a MeanSD.

References: Computing Higher-Order Moments Online. http://people.xiph.org/~tterribe/notes/homs.html

Alias This

toMeanSD

Members

Functions

put
void put(double element)
put
void put(typeof(this) rhs)

Combine two Summary's.

toString
string toString()

Properties

N
double N [@property getter]
kurtosis
double kurtosis [@property getter]
max
double max [@property getter]
mean
double mean [@property getter]
min
double min [@property getter]
mse
double mse [@property getter]

Mean squared error. In other words, a biased estimate of variance.

skewness
double skewness [@property getter]
stdev
double stdev [@property getter]
sum
double sum [@property getter]
toMeanSD
MeanSD toMeanSD [@property getter]

Converts this struct to a MeanSD. Called via alias this when an implicit conversion is attetmpted.

var
double var [@property getter]

Examples

1 Summary summ;
2 summ.put(1);
3 summ.put(2);
4 summ.put(3);
5 summ.put(4);
6 summ.put(5);
7 assert(summ.N == 5);
8 assert(summ.mean == 3);
9 assert(summ.stdev == sqrt(2.5));
10 assert(summ.var == 2.5);
11 assert(approxEqual(summ.kurtosis, -1.9120));
12 assert(summ.min == 1);
13 assert(summ.max == 5);
14 assert(summ.sum == 15);

Meta