Statistic

Undocumented in source.

Members

Aliases

Result
alias Result = Tuple!(double, "sigma", double, "mean", uint, "N", T, "min", T, "max")
Undocumented in source.

Functions

contains
bool contains(T size)
Undocumented in source. Be warned that the author may not have intended to support it.
histogram
const(uint[T]) histogram()
Undocumented in source. Be warned that the author may not have intended to support it.
histogramString
string histogramString(bool logscale, uint axis_scale)
Undocumented in source. Be warned that the author may not have intended to support it.
opCall
void opCall(T value)
Undocumented in source. Be warned that the author may not have intended to support it.
result
const(Result) result()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Mixins

__anonymous
mixin HiBONRecord
Undocumented in source.

Variables

N
uint N;
Undocumented in source.
_histogram
uint[T] _histogram;
Undocumented in source.
_max
T _max;
Undocumented in source.
_min
T _min;
Undocumented in source.
sum
double sum;
Undocumented in source.
sum2
double sum2;
Undocumented in source.

Mixed In Members

From mixin HiBONRecord

check
alias check = Check!(HiBONRecordException)
Undocumented in source.
__anonymous
mixin JSONString
Undocumented in source.
__anonymous
mixin HiBONRecordType
Undocumented in source.
isRecord
alias isRecord = HiBONRecord.isRecord!ThisType
Undocumented in source.
HAS_TYPE
enum HAS_TYPE;
Undocumented in source.
less_than
bool less_than(Key a, Key b)
Undocumented in source. Be warned that the author may not have intended to support it.
toHiBON
inout(HiBON) toHiBON()
Undocumented in source. Be warned that the author may not have intended to support it.
NO_DEFAULT_CTOR
enum NO_DEFAULT_CTOR;
Undocumented in source.
GetKeyName
template GetKeyName(uint i)
Undocumented in source.
_keys
string[] _keys()
keys
enum keys;
Undocumented in source.
this
this(HiBON hibon)
Undocumented in source.
this
this(Document doc)
Undocumented in source.
serialize
immutable(ubyte[]) serialize()
Undocumented in source. Be warned that the author may not have intended to support it.
toDoc
const(Document) toDoc()
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

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);

Meta