Class MannWhitneyUTest
 java.lang.Object

 org.hipparchus.stat.inference.MannWhitneyUTest

public class MannWhitneyUTest extends Object
An implementation of the MannWhitney U test.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 andCORRECT
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 Summary
Constructors Constructor 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.

Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.



Constructor Detail

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

MannWhitneyUTest
public MannWhitneyUTest(NaNStrategy nanStrategy, TiesStrategy tiesStrategy)
Create a test instance using the given strategies for NaN's and ties. Parameters:
nanStrategy
 specifies the strategy that should be used for Double.NaN'stiesStrategy
 specifies the strategy that should be used for ties


Method Detail

mannWhitneyU
public double mannWhitneyU(double[] x, double[] y) throws MathIllegalArgumentException, NullArgumentException
Computes the MannWhitney U statistic comparing means for two independent samples possibly of different lengths.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:
 All observations in the two samples are independent.
 The observations are at least ordinal (continuous are also ordinal).
 Parameters:
x
 the first sampley
 the second sample Returns:
 MannWhitney U statistic (minimum of U^{x} and U^{y})
 Throws:
NullArgumentException
 ifx
ory
arenull
.MathIllegalArgumentException
 ifx
ory
are zerolength.

mannWhitneyUTest
public double mannWhitneyUTest(double[] x, double[] y) throws MathIllegalArgumentException, NullArgumentException
Returns the asymptotic observed significance level, or pvalue, associated with a MannWhitney U Test comparing means for two independent samples.Let X_{i} denote the i'th individual of the first sample and Y_{j} the j'th individual in the second sample.
Preconditions:
 All observations in the two samples are independent.
 The observations are at least ordinal.
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.
 Parameters:
x
 the first sampley
 the second sample Returns:
 approximate 2sized pvalue
 Throws:
NullArgumentException
 ifx
ory
arenull
.MathIllegalArgumentException
 ifx
ory
are zerolength

mannWhitneyUTest
public double mannWhitneyUTest(double[] x, double[] y, boolean exact) throws MathIllegalArgumentException, NullArgumentException
Returns the asymptotic observed significance level, or pvalue, associated with a MannWhitney U Test comparing means for two independent samples.Let X_{i} denote the i'th individual of the first sample and Y_{j} the j'th individual in the second sample.
Preconditions:
 All observations in the two samples are independent.
 The observations are at least ordinal.
If
exact
istrue
, 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
isfalse
, the normal approximation is used to estimate the pvalue.If the combined dataset contains ties and
exact
istrue
, MathIllegalArgumentException is thrown. Ifexact
isfalse
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. Parameters:
x
 the first sampley
 the second sampleexact
 true means compute the pvalue exactly, false means use the normal approximation Returns:
 approximate 2sided pvalue
 Throws:
NullArgumentException
 ifx
ory
arenull
.MathIllegalArgumentException
 ifx
ory
are zerolength or ifexact
istrue
and ties are present in the data

