UNPKG

ts-scikit

Version:

A scientific toolkit written in Typescript

106 lines (105 loc) 3.21 kB
import { Sampling } from './sampling'; /** * A histogram. * <p> * A histogram summarizes the distribution of values v in an array. * The range (vmax - vmin) of values v in the array is partitioned uniformly * into some number of bins. Each bin then contains the number of values * that lie closest to the center of that bin. * <p> * If the values v in the array are assumed to be instances of some random * variable, then a probability density function may be estimated for that * variable by simply dividing the count in each bin by the total number of * values in that array. The resulting functions are called the densities. * <p> * The number of bins may be specified or computed automatically. In the * automatic case, we compute bin width as: * <pre><code> * w = 2.0 * (v75 - v25) / pow(n, 1.0/3.0), * </code></pre> * where n denotes the number of values, and v25 and v75 are the 25th and * 75th percentiles, respectively. The number of bins is then computed by * dividing the range (vmax - vmin) of values by that bin width, rounding * down to the nearest integer. In this way, the number of bins grows * as the cube root of the number of values n. * <p> * Minimum and maximum values (vmin and vmax) may also be specified or * computed automatically. If specified, then only the values in the range * [vmin, vmax] are binned, and values outside this range are ignored. * <p> * Reference: Izenman, A. J., 1991, Recent developments in nonparametric * density estimation: Journal of the American Statistical Association, * v. 86, p. 205-224. */ export declare class Histogram { private _vmin; private _vmax; private _computedMinMax; private _sbin; private _h; private _nin; private _nlo; private _nhi; /** * Constructs a new histogram. * <p> * The min and max bin values are computed automatically, unless the user * provides a min and max value. * @param v an array of numbers. * @param nbin the number of bins. * @param vmin the minimum value (optional). * @param vmax the maximum value (optional). */ constructor(v: number[], nbin: number, vmin?: number, vmax?: number); /** * Gets the min value. */ get min(): number; /** * Gets the max value. */ get max(): number; /** * Gets the bin count. */ get binCount(): number; /** * Gets the bin delta. */ get binDelta(): number; /** * Gets the first bin value. */ get binFirst(): number; /** * Gets the bin sampling. */ get binSampling(): Sampling; /** * Gets the counts. */ get counts(): number[]; /** * Gets the count of values in the range. */ get inCount(): number; /** * Gets the count of values too low. */ get lowCount(): number; /** * Gets the count of values too high. */ get highCount(): number; /** * Gets the densities. */ get densities(): number[]; /** * Initializes the histogram. If nbin is zero, then this method computes * the number of bins. */ private init; private initMinMax; private trim; }