online-histogram (no tests yet!)
Online histogram calculation (piece-by-piece)
Parameters
maxBins
- max number of bins. Total number of bins will be in range (maxBins/2, maxBins)toTrim
(defaultfalse
) - iftrue
zeros will be removed from both histogram tails
Usage
const Histogram = // Create a new histogram object calling Histogram() or new Histogram()// Each of those object stores histogram values and other variables like min/max// We need this extra step to be able to calculate histograms of multiple data flowsconst h1 = const h2 = 20 true // same as const h2 = Histogram(20, true) // Update calling histogram objects directly, as a function:;1 2 3 4 5 // Or via .fit() method. These two ways are identical!;4 5 6 7 8 // Using with arrays: // Keep in mind - this line updates existing histogram `h1` with 3 new data values // Get histogram calling histogram object with no arguments:console // Or via .value getterconsole // Total number of observations:console // 'n' and 'value' are not just object keys, but object getters.