# kruskalWallisTest

> **kruskalWallisTest**(`groups`): [`KruskalWallisTestResult`](/reference/knotkit/hypothesis-test/interfaces/kruskalwallistestresult/)

Defined in: [packages/hypothesis-test/src/kruskal-wallis-test.ts:27](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/hypothesis-test/src/kruskal-wallis-test.ts#L27)

Kruskal-Wallis H-test of whether `k >= 2` independent groups come from the same distribution, matching `scipy.stats.kruskal`. The p-value is the upper tail of the chi-squared distribution with `k - 1` degrees of freedom, so there is no `alternative`, and it is an approximation that is unreliable for groups of fewer than about five values. Uses `O(N log N)` time and `O(N)` space for `N` observations.

When every observation is equal the tie correction is zero. SciPy returns NaN there; this function throws.

## Parameters

### groups

`ArrayLike`<`ArrayLike`<`number`>>

## Returns

[`KruskalWallisTestResult`](/reference/knotkit/hypothesis-test/interfaces/kruskalwallistestresult/)

## Throws

With `TOO_FEW_GROUPS` below two groups, `EMPTY_SAMPLE`, `NON_FINITE_SAMPLE`, or `ZERO_VARIANCE`.

## Throws

With `INVALID_PARAMETER` above the supported number of groups.
