public class MannWhitneyUTest extends Object
The definitions and computing formulas used in this implementation follow those in the article, MannWhitney U Test
In general, results correspond to (and have been tested against) the R
wilcox.test function, with exact
meaning the same thing in both APIs
and CORRECT
uniformly true in this implementation. For example,
wilcox.test(x, y, alternative = "two.sided", mu = 0, paired = FALSE, exact = FALSE
correct = TRUE) will return the same pvalue as mannWhitneyUTest(x, y,
false). The minimum of the W value returned by R for wilcox.test(x, y...) and
wilcox.test(y, x...) should equal mannWhitneyU(x, y...).
Constructor and Description 

MannWhitneyUTest()
Create a test instance using where NaN's are left in place and ties get
the average of applicable ranks.

MannWhitneyUTest(NaNStrategy nanStrategy,
TiesStrategy tiesStrategy)
Create a test instance using the given strategies for NaN's and ties.

Modifier and Type  Method and Description 

double 
mannWhitneyU(double[] x,
double[] y)
Computes the
MannWhitney U statistic comparing means for two independent samples
possibly of different lengths.

double 
mannWhitneyUTest(double[] x,
double[] y)
Returns the asymptotic observed significance level, or
pvalue, associated with a MannWhitney U
Test comparing means for two independent samples.

double 
mannWhitneyUTest(double[] x,
double[] y,
boolean exact)
Returns the asymptotic observed significance level, or
pvalue, associated with a MannWhitney U
Test comparing means for two independent samples.

public MannWhitneyUTest()
public MannWhitneyUTest(NaNStrategy nanStrategy, TiesStrategy tiesStrategy)
nanStrategy
 specifies the strategy that should be used for
Double.NaN'stiesStrategy
 specifies the strategy that should be used for tiespublic double mannWhitneyU(double[] x, double[] y) throws MathIllegalArgumentException, NullArgumentException
This statistic can be used to perform a MannWhitney U test evaluating the null hypothesis that the two independent samples have equal mean.
Let X_{i} denote the i'th individual of the first sample and Y_{j} the j'th individual in the second sample. Note that the samples can have different lengths.
Preconditions:
x
 the first sampley
 the second sampleNullArgumentException
 if x
or y
are null
.MathIllegalArgumentException
 if x
or y
are
zerolength.public double mannWhitneyUTest(double[] x, double[] y) throws MathIllegalArgumentException, NullArgumentException
Let X_{i} denote the i'th individual of the first sample and Y_{j} the j'th individual in the second sample.
Preconditions:
If there are no ties in the data and both samples are small (less than or equal to 50 values in the combined dataset), an exact test is performed; otherwise the test uses the normal approximation (with continuity correction).
If the combined dataset contains ties, the variance used in the normal approximation is biasadjusted using the formula in the reference above.
x
 the first sampley
 the second sampleNullArgumentException
 if x
or y
are null
.MathIllegalArgumentException
 if x
or y
are
zerolengthpublic double mannWhitneyUTest(double[] x, double[] y, boolean exact) throws MathIllegalArgumentException, NullArgumentException
Let X_{i} denote the i'th individual of the first sample and Y_{j} the j'th individual in the second sample.
Preconditions:
If exact
is true
, the pvalue reported is exact, computed
using the exact distribution of the U statistic. The computation in this
case requires storage on the order of the product of the two sample
sizes, so this should not be used for large samples.
If exact
is false
, the normal approximation is used to
estimate the pvalue.
If the combined dataset contains ties and exact
is true
,
MathIllegalArgumentException is thrown. If exact
is false
and the ties are present, the variance used to compute the approximate
pvalue in the normal approximation is biasadjusted using the formula in
the reference above.
x
 the first sampley
 the second sampleexact
 true means compute the pvalue exactly, false means use the
normal approximationNullArgumentException
 if x
or y
are null
.MathIllegalArgumentException
 if x
or y
are
zerolength or if exact
is true
and ties are
present in the dataCopyright © 20162022 CS GROUP. All rights reserved.