# covariance

> **covariance**(`first`, `second`, `options?`): `number`

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

Covariance by Welford’s one-pass co-moment update. The divisor is `length - degreesOfFreedomCorrection`; the default `1` is the unbiased sample covariance.

## Parameters

### first

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

### second

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

### options?

[`SampleMomentOptions`](/reference/knotkit/distribution/interfaces/samplemomentoptions/)

## Returns

`number`

## Throws

`INVALID_PARAMETER` when the correction is not a nonnegative integer; `INVALID_SAMPLE` when the lengths differ, a value is non-finite, or the length does not exceed the correction.
