Class MannWhitneyUTest
- Since:
- 1.1
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classResult for the Mann-Whitney U test. -
Method Summary
Modifier and TypeMethodDescriptiondoublestatistic(double[] x, double[] y) Computes the Mann-Whitney U statistic comparing two independent samples possibly of different length.test(double[] x, double[] y) Performs a Mann-Whitney U test comparing the location for two independent samples.Return an instance with the configured alternative hypothesis.Return an instance with the configured continuity correction.with(PValueMethod v) Return an instance with the configured p-value method.static MannWhitneyUTestReturn an instance using the default options.withMu(double v) Return an instance with the configured location shiftmu.
-
Method Details
-
withDefaults
Return an instance using the default options.- Returns:
- default instance
-
with
Return an instance with the configured alternative hypothesis.- Parameters:
v- Value.- Returns:
- an instance
-
with
Return an instance with the configured p-value method.- Parameters:
v- Value.- Returns:
- an instance
- Throws:
IllegalArgumentException- if the value is not in the allowed options or is null
-
with
Return an instance with the configured continuity correction.If
ENABLED, adjust the U rank statistic by 0.5 towards the mean value when computing the z-statistic if a normal approximation is used to compute the p-value.- Parameters:
v- Value.- Returns:
- an instance
-
withMu
Return an instance with the configured location shiftmu.- Parameters:
v- Value.- Returns:
- an instance
- Throws:
IllegalArgumentException- if the value is not finite
-
statistic
Computes the Mann-Whitney U statistic comparing two independent samples possibly of different length.This statistic can be used to perform a Mann-Whitney U test evaluating the null hypothesis that the two independent samples differ by a location shift of
mu.This returns the U1 statistic. Compute the U2 statistic using:
u2 = (long) x.length * y.length - u1;
- Parameters:
x- First sample values.y- Second sample values.- Returns:
- Mann-Whitney U1 statistic
- Throws:
IllegalArgumentException- ifxoryare zero-length; or contain NaN values.- See Also:
-
test
Performs a Mann-Whitney U test comparing the location for two independent samples. The location is specified usingmu.The test is defined by the
AlternativeHypothesis.- 'two-sided': the distribution underlying
(x - mu)is not equal to the distribution underlyingy. - 'greater': the distribution underlying
(x - mu)is stochastically greater than the distribution underlyingy. - 'less': the distribution underlying
(x - mu)is stochastically less than the distribution underlyingy.
If the p-value method is auto an exact p-value is computed if the samples contain less than 50 values; otherwise a normal approximation is used.
Computation of the exact p-value is only valid if there are no tied ranks in the data; otherwise the p-value resorts to the asymptotic approximation using a tie correction and an optional continuity correction.
Note: Exact computation requires tabulation of values not exceeding size
(n+1)*(m+1)*(u+1)whereuis the minimum of the U1 and U2 statistics andnandmare the sample sizes. This may use a very large amount of memory and result in anOutOfMemoryError. Exact computation requires a finite binomial coefficientbinom(n+m, m)which is limited ton+m <= 1029for anynandm, ormin(n, m) <= 37for anymax(n, m). AnOutOfMemoryErroris not expected using the limits configured for the auto p-value computation as the maximum required memory is approximately 23 MiB.- Parameters:
x- First sample values.y- Second sample values.- Returns:
- test result
- Throws:
IllegalArgumentException- ifxoryare zero-length; or contain NaN values.OutOfMemoryError- if the exact computation is user-requested for large samples and there is not enough memory.- See Also:
- 'two-sided': the distribution underlying
-