# totalVariationDistance

> **totalVariationDistance**(`first`, `second`): `number`

Defined in: [packages/distance/src/total-variation.ts:10](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/distance/src/total-variation.ts#L10)

Largest absolute difference in event probability for two probability vectors on the same ordered outcomes. Accepted vectors are normalized by their totals. Returns a distance in \[0, 1] in O(n) time and O(1) extra space.

## Parameters

### first

[`NumericVector`](/reference/knotkit/distance/type-aliases/numericvector/)

### second

[`NumericVector`](/reference/knotkit/distance/type-aliases/numericvector/)

## Returns

`number`

## Throws

With `INVALID_DIMENSION` or `INVALID_PROBABILITIES`.
