# pearsonCorrelation

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

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

Pearson product-moment correlation coefficient, clamped to \[-1, 1] against floating-point overshoot.

## Parameters

### first

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

### second

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

## Returns

`number`

## Throws

`INVALID_SAMPLE` when the lengths differ, a sample holds fewer than 2 values, or a value is non-finite; `ZERO_VARIANCE` when either sample is constant.
