histogram — 6.0.0

Bin raw samples or normalize pre-counted buckets into numeric data suitable for plot.

Signature

Signature
histogram(values, options?: HistogramOptions): HistogramData

Executable examples

Histogram bins

Source
histogram([1, 1, 2, 2, 2, 4], { binCount: 3 });
Terminal output
[
  [
    1.5,
    2
  ],
  [
    2.5,
    3
  ],
  [
    3.5,
    1
  ]
]

HistogramOptions

Options for deriving histogram bins from raw samples.

type HistogramOptions = {
  /** Positive integer bin count. Defaults to Sturges' formula. */
  binCount?: number;
};

binCount

numberOptional

Positive integer bin count. Defaults to Sturges' formula.

Related executable examples: Histogram bins