org.apache.commons.math.stat.inference
Class WilcoxonSignedRankTestImpl

java.lang.Object
  extended by org.apache.commons.math.stat.inference.WilcoxonSignedRankTestImpl
All Implemented Interfaces:
WilcoxonSignedRankTest

public class WilcoxonSignedRankTestImpl
extends java.lang.Object
implements WilcoxonSignedRankTest

An implementation of the Wilcoxon signed-rank test.

Version:
$Id: WilcoxonSignedRankTestImpl.java 1131229 2011-06-03 20:49:25Z luc $

Constructor Summary
WilcoxonSignedRankTestImpl()
          Create a test instance where NaN's are left in place and ties get the average of applicable ranks.
WilcoxonSignedRankTestImpl(NaNStrategy nanStrategy, TiesStrategy tiesStrategy)
          Create a test instance using the given strategies for NaN's and ties.
 
Method Summary
 double wilcoxonSignedRank(double[] x, double[] y)
          Computes the Wilcoxon signed ranked statistic comparing mean 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 p-value, associated with a Wilcoxon signed ranked statistic comparing mean for two related samples or repeated measurements on a single sample.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WilcoxonSignedRankTestImpl

public WilcoxonSignedRankTestImpl()
Create a test instance where NaN's are left in place and ties get the average of applicable ranks. Use this unless you are very sure of what you are doing.


WilcoxonSignedRankTestImpl

public WilcoxonSignedRankTestImpl(NaNStrategy nanStrategy,
                                  TiesStrategy tiesStrategy)
Create a test instance using the given strategies for NaN's and ties. Only use this if you are sure of what you are doing.

Parameters:
nanStrategy - specifies the strategy that should be used for Double.NaN's
tiesStrategy - specifies the strategy that should be used for ties
Method Detail

wilcoxonSignedRank

public double wilcoxonSignedRank(double[] x,
                                 double[] y)
                          throws java.lang.IllegalArgumentException
Computes the Wilcoxon signed ranked statistic comparing mean 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 has equal mean.

Let Xi denote the i'th individual of the first sample and Yi the related i'th individual in the second sample. Let Zi = Yi - Xi.

Preconditions:

Specified by:
wilcoxonSignedRank in interface WilcoxonSignedRankTest
Parameters:
x - the first sample
y - the second sample
Returns:
wilcoxonSignedRank statistic (the larger of W+ and W-)
Throws:
java.lang.IllegalArgumentException - if preconditions are not met

wilcoxonSignedRankTest

public double wilcoxonSignedRankTest(double[] x,
                                     double[] y,
                                     boolean exactPValue)
                              throws java.lang.IllegalArgumentException,
                                     MathException
Returns the observed significance level, or p-value, associated with a Wilcoxon signed ranked statistic comparing mean for two related samples or repeated measurements on a single sample.

Let Xi denote the i'th individual of the first sample and Yi the related i'th individual in the second sample. Let Zi = Yi - Xi.

Preconditions:

Specified by:
wilcoxonSignedRankTest in interface WilcoxonSignedRankTest
Parameters:
x - the first sample
y - the second sample
exactPValue - if the exact p-value is wanted (only for x.length <= 30)
Returns:
p-value
Throws:
java.lang.IllegalArgumentException - if preconditions are not met or exact p-value is wanted for when x.length > 30
MathException - if an error occurs computing the p-value


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.