/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.stat.inference;
import org.apache.commons.math.MathException;
/**
* An interface for Wilcoxon signed-rank test.
*
* @version $Id: WilcoxonSignedRankTest.java 1131229 2011-06-03 20:49:25Z luc $
*/
public interface WilcoxonSignedRankTest {
/**
* Computes the <a
* href="http://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test">
* Wilcoxon signed ranked statistic</a> comparing mean for two related
* samples or repeated measurements on a single sample.
* <p>
* 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.
* </p>
* <p>
* Let X<sub>i</sub> denote the i'th individual of the first sample and
* Y<sub>i</sub> the related i'th individual in the second sample. Let
* Z<sub>i</sub> = Y<sub>i</sub> - X<sub>i</sub>.
* </p>
* <p>
* <strong>Preconditions</strong>:
* <ul>
* <li>The differences Z<sub>i</sub> must be independent.</li>
* <li>Each Z<sub>i</sub> comes from a continuous population (they must be
* identical) and is symmetric about a common median.</li>
* <li>The values that X<sub>i</sub> and Y<sub>i</sub> represent are
* ordered, so the comparisons greater than, less than, and equal to are
* meaningful.</li>
* </ul>
* </p>
*
* @param x
* the first sample
* @param y
* the second sample
* @return wilcoxonSignedRank statistic
* @throws IllegalArgumentException
* if preconditions are not met
*/
double wilcoxonSignedRank(final double[] x, final double[] y)
throws IllegalArgumentException;
/**
* Returns the <i>observed significance level</i>, or <a href=
* "http://www.cas.lancs.ac.uk/glossary_v1.1/hyptest.html#pvalue">
* p-value</a>, associated with a <a
* href="http://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test">
* Wilcoxon signed ranked statistic</a> comparing mean for two related
* samples or repeated measurements on a single sample.
* <p>
* Let X<sub>i</sub> denote the i'th individual of the first sample and
* Y<sub>i</sub> the related i'th individual in the second sample. Let
* Z<sub>i</sub> = Y<sub>i</sub> - X<sub>i</sub>.
* </p>
* <p>
* <strong>Preconditions</strong>:
* <ul>
* <li>The differences Z<sub>i</sub> must be independent.</li>
* <li>Each Z<sub>i</sub> comes from a continuous population (they must be
* identical) and is symmetric about a common median.</li>
* <li>The values that X<sub>i</sub> and Y<sub>i</sub> represent are
* ordered, so the comparisons greater than, less than, and equal to are
* meaningful.</li>
* </ul>
* </p>
*
* @param x
* the first sample
* @param y
* the second sample
* @param exactPValue
* if the exact p-value is wanted (only works for x.length <= 30,
* if true and x.length > 30, this is ignored because
* calculations may take too long)
* @return p-value
* @throws IllegalArgumentException
* if preconditions are not met
* @throws MathException
* if an error occurs computing the p-value
*/
double wilcoxonSignedRankTest(final double[] x, final double[] y,
boolean exactPValue) throws IllegalArgumentException,
MathException;
}