Package org.hipparchus.stat.inference
Class WilcoxonSignedRankTest
 java.lang.Object

 org.hipparchus.stat.inference.WilcoxonSignedRankTest

public class WilcoxonSignedRankTest extends Object
An implementation of the Wilcoxon signedrank test. This implementation currently handles only paired (equal length) samples and discards tied pairs from the analysis. The latter behavior differs from the R implementation of wilcox.test and corresponds to the "wilcox" zero_method configurable in scipy.stats.wilcoxon.


Constructor Summary
Constructors Constructor Description WilcoxonSignedRankTest()
Create a test instance where NaN's are left in place and ties get the average of applicable ranks.WilcoxonSignedRankTest(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
wilcoxonSignedRank(double[] x, double[] y)
Computes the Wilcoxon signed ranked statistic comparing means for two related samples or repeated measurements on a single sample.double
wilcoxonSignedRankTest(double[] x, double[] y, boolean exactPValue)
Returns the observed significance level, or pvalue, associated with a Wilcoxon signed ranked statistic comparing mean for two related samples or repeated measurements on a single sample.



Constructor Detail

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

WilcoxonSignedRankTest
public WilcoxonSignedRankTest(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

wilcoxonSignedRank
public double wilcoxonSignedRank(double[] x, double[] y) throws MathIllegalArgumentException, NullArgumentException
Computes the Wilcoxon signed ranked statistic comparing means for two related samples or repeated measurements on a single sample.This statistic can be used to perform a Wilcoxon signed ranked test evaluating the null hypothesis that the two related samples or repeated measurements on a single sample have equal mean.
Let X_{i} denote the i'th individual of the first sample and Y_{i} the related i'th individual in the second sample. Let Z_{i} = Y_{i}  X_{i}.
Preconditions:
 The differences Z_{i} must be independent.
 Each Z_{i} comes from a continuous population (they must be identical) and is symmetric about a common median.
 The values that X_{i} and Y_{i} represent are ordered, so the comparisons greater than, less than, and equal to are meaningful.
 Parameters:
x
 the first sampley
 the second sample Returns:
 wilcoxonSignedRank statistic (the larger of W+ and W)
 Throws:
NullArgumentException
 ifx
ory
arenull
.MathIllegalArgumentException
 ifx
ory
are zerolength.MathIllegalArgumentException
 ifx
andy
do not have the same length.

wilcoxonSignedRankTest
public double wilcoxonSignedRankTest(double[] x, double[] y, boolean exactPValue) throws MathIllegalArgumentException, NullArgumentException, MathIllegalStateException
Returns the observed significance level, or pvalue, associated with a Wilcoxon signed ranked statistic comparing mean for two related samples or repeated measurements on a single sample.Let X_{i} denote the i'th individual of the first sample and Y_{i} the related i'th individual in the second sample. Let Z_{i} = Y_{i}  X_{i}.
Preconditions:
 The differences Z_{i} must be independent.
 Each Z_{i} comes from a continuous population (they must be identical) and is symmetric about a common median.
 The values that X_{i} and Y_{i} represent are ordered, so the comparisons greater than, less than, and equal to are meaningful.
 Tied pairs are discarded from the data.
 When
exactPValue
is false, the normal approximation is used to estimate the pvalue including a continuity correction factor.wilcoxonSignedRankTest(x, y, true)
should give the same results aswilcox.test(x, y, alternative = "two.sided", mu = 0, paired = TRUE, exact = FALSE, correct = TRUE)
in R (as long as there are no tied pairs in the data).
 Parameters:
x
 the first sampley
 the second sampleexactPValue
 if the exact pvalue is wanted (only works for x.length <= 30, if true and x.length > 30, MathIllegalArgumentException is thrown) Returns:
 pvalue
 Throws:
NullArgumentException
 ifx
ory
arenull
.MathIllegalArgumentException
 ifx
ory
are zerolength or for all i, x[i] == y[i]MathIllegalArgumentException
 ifx
andy
do not have the same length.MathIllegalArgumentException
 ifexactPValue
istrue
andx.length
> 30MathIllegalStateException
 if the pvalue can not be computed due to a convergence errorMathIllegalStateException
 if the maximum number of iterations is exceeded

