Struct 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.
struct Summary
;
Properties
Name | Type | Description |
---|---|---|
kurtosis [get]
|
double | |
max [get]
|
double | |
mean [get]
|
double | |
min [get]
|
double | |
mse [get]
|
double | Mean squared error. In other words, a biased estimate of variance. |
N [get]
|
double | |
skewness [get]
|
double | |
stdev [get]
|
double | |
sum [get]
|
double | |
toMeanSD [get]
|
MeanSD | Converts this struct to a MeanSD. Called via alias this when an implicit conversion is attetmpted. |
var [get]
|
double |
Methods
Name | Description |
---|---|
put
|
|
put
|
Combine two Summary's. |
toString
|
Note
This struct can implicitly convert to a MeanSD.
References
Computing Higher-Order Moments Online.
http
//people.xiph.org/~tterribe/notes/homs.html
Examples
Summary summ;
summ .put(1);
summ .put(2);
summ .put(3);
summ .put(4);
summ .put(5);
assert(summ .N == 5);
assert(summ .mean == 3);
assert(summ .stdev == sqrt(2.5));
assert(summ .var == 2.5);
assert(approxEqual(summ .kurtosis, -1.9120));
assert(summ .min == 1);
assert(summ .max == 5);
assert(summ .sum == 15);