# median

> **median**(`values`): `number`

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

Exact median of a copy of `values`: the middle value, or the mean of the two middle values. The input is not mutated.

## Parameters

### values

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

## Returns

`number`

## Throws

`INVALID_SAMPLE` when `values` is empty or holds a non-finite value.
