mannWhitneyUTest
fun mannWhitneyUTest(sample1: DoubleArray, sample2: DoubleArray, alternative: Alternative = Alternative.TWO_SIDED): TestResult(source)
Performs the Mann-Whitney U test (also known as the Wilcoxon rank-sum test).
The null hypothesis is that the two samples are drawn from the same distribution. This is a non-parametric test that does not assume normality — it compares the ranks of the combined samples rather than the raw values. Uses a normal approximation for computing the p-value.
Example:
val control = doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0)
val treatment = doubleArrayOf(6.0, 7.0, 8.0, 9.0, 10.0)
val result = mannWhitneyUTest(control, treatment)
result.statistic // U statistic (minimum of U1 and U2)
result.pValue // p-value
result.additionalInfo["U1"] // U statistic for sample 1
result.additionalInfo["U2"] // U statistic for sample 2
result.additionalInfo["z"] // z-score from normal approximationContent copied to clipboard
Return
a TestResult containing the U statistic (minimum of U1 and U2), p-value, and additional info with "U1", "U2", and "z".
Parameters
sample1
the first sample. Must not be empty.
sample2
the second sample. Must not be empty.
alternative
the direction of the alternative hypothesis. Defaults to Alternative.TWO_SIDED.