# histogram

> **histogram**(`values`, `options`): [`Histogram`](/reference/knotkit/distribution/interfaces/histogram/)

Defined in: [packages/distribution/src/sample-statistics.ts:210](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/distribution/src/sample-statistics.ts#L210)

Histogram with NumPy’s `np.histogram` semantics: bin `i` is `[edges[i], edges[i + 1])` and the last bin is closed on both ends. `{ bins }` spans the sample’s range with equal-width bins, widened by 0.5 on each side when the sample is constant. `{ edges }` uses the supplied edges, and values outside them are not counted. The input is not mutated.

## Parameters

### values

[`NumericSample`](/reference/knotkit/distribution/type-aliases/numericsample/)

### options

[`HistogramOptions`](/reference/knotkit/distribution/type-aliases/histogramoptions/)

## Returns

[`Histogram`](/reference/knotkit/distribution/interfaces/histogram/)

## Throws

`INVALID_SAMPLE` when `values` is empty or holds a non-finite value; `INVALID_PARAMETER` when `bins` is not a positive integer or `edges` are not at least 2 finite, strictly increasing numbers.
