Statistic!uint s;
const samples = [10, 15, 17, 6, 8, 12, 18];
samples.each!(a => s(a));
auto r = s.result;
// Mean
assert(approx(r.mean, 12.2857));
// Number of samples
assert(r.N == samples.length);
// Sigma
assert(approx(r.sigma, 4.5721));
assert(r.max == samples.maxElement);
assert(r.min == samples.minElement);
/// Use of the Statistic including histogram
Statistic!(long, Yes.histogram) s;
const samples = [-10, 15, -10, 6, 8, -12, 18, 8, -12, 9, 4, 5, 6];
samples.each!(n => s(n));
auto r = s.result;
// Mean
assert(approx(r.mean, 2.6923));
// Number of samples
assert(r.N == samples.length);
// Sigma
assert(approx(r.sigma, 10.266));
assert(r.max == samples.maxElement);
assert(r.min == samples.minElement);
// samples/histogram does not contain -4
assert(!s.contains(-4));
// but conatians -10
assert(s.contains(-10));
// Get the statiscal histogram
const histogram = s.histogram;
assert(histogram.get(-4, 0) == 0);
assert(histogram.get(-10, 0) > 0);
// verifies the number of samples in the histogram
assert(histogram.get(-10, 0) == samples.filter!(a => a == -10).count);