# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.test.rank.wilcoxon

## Class WilcoxonSignedRank

• public class WilcoxonSignedRank
extends HypothesisTest
The Wilcoxon signed rank test tests, for the one-sample case, the median of the distribution against a hypothetical median, and for the two-sample case, the equality of medians of groups. Unlike the Student's t-test, the Wilcoxon signed rank test does not assume any distribution of the population.

The R equivalent function is wilcox.test.

• ### Constructor Summary

Constructors
Constructor and Description
WilcoxonSignedRank(double[] sample)
Perform the Wilcoxon Signed Rank test to test for the equality of medians.
WilcoxonSignedRank(double[] sample1, double[] sample2)
Perform the Wilcoxon Signed Rank test to test for the equality of medians.
WilcoxonSignedRank(double[] sample1, double[] sample2, double mu, boolean isExact)
Perform the Wilcoxon Signed Rank test to test for the equality of medians.
WilcoxonSignedRank(double[] sample, int mu)
Perform the Wilcoxon Signed Rank test to test for the equality of medians.
• ### Method Summary

All Methods
Modifier and Type Method and Description
String getAlternativeHypothesis()
Get the description of the alternative hypothesis.
String getNullHypothesis()
Get a description of the null hypothesis.
double leftOneSidedPvalue()
Get the left, one-sided p-value.
double pValue()
Get the p-value for the test statistics.
double rightOneSidedPvalue()
Get the right, one-sided p-value.
double statistics()
Get the test statistics.
• ### Methods inherited from class com.numericalmethod.suanshu.stats.test.HypothesisTest

isNullRejected, nGroups, nObs, oneSidedPvalue
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### WilcoxonSignedRank

public WilcoxonSignedRank(double[] sample1,
double[] sample2,
double mu,
boolean isExact)
Perform the Wilcoxon Signed Rank test to test for the equality of medians.
Parameters:
sample1 - sample 1
sample2 - sample 2
mu - the hypothetical median that the distribution is symmetric about
isExact - true if to use the exact distribution; otherwise, normal approximation is used
• #### WilcoxonSignedRank

public WilcoxonSignedRank(double[] sample1,
double[] sample2)
Perform the Wilcoxon Signed Rank test to test for the equality of medians.
Parameters:
sample1 - sample 1
sample2 - sample 2
• #### WilcoxonSignedRank

public WilcoxonSignedRank(double[] sample,
int mu)
Perform the Wilcoxon Signed Rank test to test for the equality of medians.
Parameters:
sample - a sample
mu - the hypothetical median that the distribution is symmetric about
• #### WilcoxonSignedRank

public WilcoxonSignedRank(double[] sample)
Perform the Wilcoxon Signed Rank test to test for the equality of medians.
Parameters:
sample - a sample
• ### Method Detail

• #### getNullHypothesis

public String getNullHypothesis()
Description copied from class: HypothesisTest
Get a description of the null hypothesis.
Specified by:
getNullHypothesis in class HypothesisTest
Returns:
the null hypothesis description
Wikipedia: Null hypothesis
• #### getAlternativeHypothesis

public String getAlternativeHypothesis()
Description copied from class: HypothesisTest
Get the description of the alternative hypothesis.
Specified by:
getAlternativeHypothesis in class HypothesisTest
Returns:
the alternative hypothesis description
Wikipedia: Alternative hypothesis
• #### statistics

public double statistics()
Description copied from class: HypothesisTest
Get the test statistics.
Specified by:
statistics in class HypothesisTest
Returns:
the test statistics
Wikipedia: Test statistic
• #### pValue

public double pValue()
Description copied from class: HypothesisTest
Get the p-value for the test statistics.
Specified by:
pValue in class HypothesisTest
Returns:
the p-value
Wikipedia: P-value
• #### rightOneSidedPvalue

public double rightOneSidedPvalue()
Get the right, one-sided p-value.
Returns:
the right, one-sided p-value.
• #### leftOneSidedPvalue

public double leftOneSidedPvalue()
Get the left, one-sided p-value.
Returns:
the left, one-sided p-value.