SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.test
Class HypothesisTest

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.test.HypothesisTest
Direct Known Subclasses:
AugmentedDickeyFuller, Bartlett, BoxPierce, BreuschPagan, BrownForsythe, ChiSquare4Independence, DAgostino, F, Glejser, HarveyGodfrey, JarqueBera, KolmogorovSmirnov, KruskalWallis, Levene, Lilliefors, OneWayANOVA, ShapiroWilk, SiegelTukey, T, VanDerWaerden, White, WilcoxonRankSum, WilcoxonSignedRank

public abstract class HypothesisTest
extends java.lang.Object

A statistical hypothesis test is a method of making decisions using experimental data. A result is called statistically significant if it is unlikely to have occurred by chance.

Specifically, given a null hypothesis, we compute the p-value of a test statistics. The p-value tells the probability of observing the observations. We often accept the alternative hypothesis, (i.e. rejects a null hypothesis) if the p-value is less than 0.05 or 0.01, corresponding respectively to a 5% or 1% chance of rejecting the null hypothesis when it is true.

See Also:

Field Summary
 int k
          number of groups of observations
 int N
          total number of observations
protected  double pValue
          p-value for the test statistics
protected  double testStatistics
          the test statistics
 
Constructor Summary
protected HypothesisTest(double[]... samples)
          Construct an instance of HypothesisTest from samples.
 
Method Summary
abstract  java.lang.String alternativeHypothesis()
          Get a description of the alternative hypothesis.
abstract  java.lang.String nullHypothesis()
          Get a description of the null hypothesis.
static double oneSidedPvalue(UnivariateDistribution F, double x)
          A one-sided P-value is the probability of observing a test statistic at least as extreme as the one observed; hence, the one-sided P-value is simply given by the complementary cumulative distribution function (survival function) for continuous distribution.
 double pValue()
          Get the p-value.
 boolean rejectNull(double alpha)
          Use p-value to check whether the null hypothesis can be rejected for given significance level (size) alpha.
 double testStatistics()
          Get the test statistics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

k

public final int k
number of groups of observations


N

public final int N
total number of observations


testStatistics

protected volatile double testStatistics
the test statistics


pValue

protected volatile double pValue
p-value for the test statistics

Constructor Detail

HypothesisTest

protected HypothesisTest(double[]... samples)
Construct an instance of HypothesisTest from samples.

Parameters:
samples - an array of samples
Method Detail

testStatistics

public double testStatistics()
Get the test statistics.

Returns:
the test statistics
See Also:
Wikipedia: Test statistic

pValue

public double pValue()
Get the p-value.

Returns:
the p-value
See Also:
Wikipedia: P-value

rejectNull

public boolean rejectNull(double alpha)
Use p-value to check whether the null hypothesis can be rejected for given significance level (size) alpha.

Parameters:
alpha - significance level (size) of test
Returns:
true iff the hypothesis is rejected due to p-value < alpha

nullHypothesis

public abstract java.lang.String nullHypothesis()
Get a description of the null hypothesis.

Returns:
the null hypothesis description
See Also:
Wikipedia: Null hypothesis

alternativeHypothesis

public abstract java.lang.String alternativeHypothesis()
Get a description of the alternative hypothesis.

Returns:
the alternative hypothesis description
See Also:
Wikipedia: Alternative hypothesis

oneSidedPvalue

public static double oneSidedPvalue(UnivariateDistribution F,
                                    double x)
A one-sided P-value is the probability of observing a test statistic at least as extreme as the one observed; hence, the one-sided P-value is simply given by the complementary cumulative distribution function (survival function) for continuous distribution.

For discrete distribution, we need to include the probability observing the critical value as well.

Parameters:
F - a univariate distribution
x - the critical value
Returns:
the p-value for the critical value

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.