/* * 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 Mann-Whitney U test (also called Wilcoxon rank-sum test). * * @version $Id: MannWhitneyUTest.java 1131229 2011-06-03 20:49:25Z luc $ */ public interface MannWhitneyUTest { /** * Computes the <a * href="http://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U"> Mann-Whitney * U statistic</a> comparing mean for two independent samples possibly of * different length. * <p> * This statistic can be used to perform a Mann-Whitney U test evaluating * the null hypothesis that the two independent samples has equal mean. * </p> * <p> * Let X<sub>i</sub> denote the i'th individual of the first sample and * Y<sub>j</sub> the j'th individual in the second sample. Note that the * samples would often have different length. * </p> * <p> * <strong>Preconditions</strong>: * <ul> * <li>All observations in the two samples are independent.</li> * <li>The observations are at least ordinal (continuous are also ordinal).</li> * </ul> * </p> * * @param x * the first sample * @param y * the second sample * @return mannWhitneyU statistic * @throws IllegalArgumentException * if preconditions are not met */ double mannWhitneyU(final double[] x, final double[] y) throws IllegalArgumentException; /** * Returns the asymptotic <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/Mann%E2%80%93Whitney_U"> Mann-Whitney * U statistic</a> comparing mean for two independent samples. * <p> * Let X<sub>i</sub> denote the i'th individual of the first sample and * Y<sub>j</sub> the j'th individual in the second sample. Note that the * samples would often have different length. * </p> * <p> * <strong>Preconditions</strong>: * <ul> * <li>All observations in the two samples are independent.</li> * <li>The observations are at least ordinal (continuous are also ordinal).</li> * </ul> * </p> * * @param x * the first sample * @param y * the second sample * @return asymptotic p-value * @throws IllegalArgumentException * if preconditions are not met * @throws MathException * if an error occurs computing the p-value */ double mannWhitneyUTest(final double[] x, final double[] y) throws IllegalArgumentException, MathException; }