Histogram
Source: histogram.js:18
Histogram of values: number of occurrences per distinct value.
Constructor
new Histogram(): HistogramInstance Methods
add(value: number, count?: number)
Add occurrences of a value.
Parameters
value(number) — The value.count(number, optional, default: 1) — The number of occurrences, defaults to 1.
getTotal(): number
Get the total number of counted values.
Returns
number— The total count.
getEntries(): Array.<HistogramEntry>
Get the histogram entries sorted by ascending value.
Returns
Array.<HistogramEntry>— The entries.
getRange(): NumberRange | undefined
Get the value range.
Returns
NumberRange| undefined— The range, undefined if empty.
getCountInRange(min?: number, max?: number): number
Get the number of values in [min, max).
Parameters
min(number, optional) — Inclusive lower bound, unbounded if undefined.max(number, optional) — Exclusive upper bound, unbounded if undefined.
Returns
number— The count.
getIntervalPercentages(
thresholds: Array.<(number|undefined)>,
): Array.<number>
Get the percentage of counts that fall in each interval defined by consecutive thresholds, relative to the total count in the intervals (values outside all intervals are not taken into account).
For thresholds [1, 5, 10], the intervals are [1, 5) and [5, 10). An undefined first or last threshold makes the interval unbounded: for [undefined, 5, undefined], the intervals are [min, 5) and [5, max], where min / max are the histogram range.
Parameters
thresholds(Array.<(number|undefined)>) — Interval bounds in ascending order, the first and last can be undefined.
Returns
Array.<number>— The percentages in [0, 100], one per interval (thresholds.length - 1entries), all 0 if no value falls in the intervals.
getStats(): Statistics | undefined
Get the statistics of the values: minimum, maximum, mean, standard deviation, median, 25th and 75th percentiles. Gives the same results as getStats (math/stats.js) on the full list of values.
Returns
Statistics| undefined— The statistics, undefined if empty.