# mannWhitneyUTest

> **mannWhitneyUTest**(`first`, `second`, `options?`): [`MannWhitneyUTestResult`](/reference/knotkit/hypothesis-test/interfaces/mannwhitneyutestresult/)

Defined in: [packages/hypothesis-test/src/mann-whitney-u-test.ts:100](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/hypothesis-test/src/mann-whitney-u-test.ts#L100)

Mann-Whitney U rank test of whether two independent samples come from the same distribution, matching `scipy.stats.mannwhitneyu`. `greater` tests that values of `first` tend to exceed values of `second`. The statistic is the U of `first`.

`auto` uses the exact null distribution when there are no tied values and the smaller sample has at most 8 values, which is SciPy’s rule, provided the distribution costs at most 2e7 steps to build; otherwise it uses the normal approximation with tie correction. `exact` with tied values truncates the statistic as SciPy does. Building the exact distribution takes `O(m² n)` time and `O(m n)` space for sizes `m <= n`.

When every value is equal the variance is zero. SciPy returns NaN there; this function throws.

## Parameters

### first

`ArrayLike`<`number`>

### second

`ArrayLike`<`number`>

### options?

[`MannWhitneyUTestOptions`](/reference/knotkit/hypothesis-test/interfaces/mannwhitneyutestoptions/)

## Returns

[`MannWhitneyUTestResult`](/reference/knotkit/hypothesis-test/interfaces/mannwhitneyutestresult/)

## Throws

With `EMPTY_SAMPLE`, `NON_FINITE_SAMPLE`, `INVALID_OPTION` (also for an `exact` method beyond the work limit), or `ZERO_VARIANCE`.
