Package dev.nm.stat.test
Class HypothesisTest
- java.lang.Object
-
- dev.nm.stat.test.HypothesisTest
-
- Direct Known Subclasses:
AndersonDarling
,AugmentedDickeyFuller
,Bartlett
,BoxPierce
,BrownForsythe
,ChiSquareIndependenceTest
,CramerVonMises2Samples
,DAgostino
,F
,FAEstimator
,Heteroskedasticity
,JarqueBera
,KolmogorovSmirnov
,KruskalWallis
,Levene
,Lilliefors
,OneWayANOVA
,ShapiroWilk
,SiegelTukey
,T
,VanDerWaerden
,WilcoxonRankSum
,WilcoxonSignedRank
public abstract class HypothesisTest extends 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 under the null. 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.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
HypothesisTest(double[]... samples)
Construct an instance ofHypothesisTest
from the samples.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract String
getAlternativeHypothesis()
Get the description of the alternative hypothesis.abstract String
getNullHypothesis()
Get a description of the null hypothesis.boolean
isNullRejected(double alpha)
Use the p-value to check whether the null hypothesis can be rejected for a given significance level.int
nGroups()
Get the number of groups of observations.int
nObs()
Get the total number of observations.static double
oneSidedPvalue(ProbabilityDistribution F, double x)
The one-sided p-value is the probability of observing a test statistic at least as extreme as the one observed.abstract double
pValue()
Get the p-value for the test statistics.abstract double
statistics()
Get the test statistics.
-
-
-
Method Detail
-
statistics
public abstract double statistics()
Get the test statistics.- Returns:
- the test statistics
- See Also:
- Wikipedia: Test statistic
-
pValue
public abstract double pValue()
Get the p-value for the test statistics.- Returns:
- the p-value
- See Also:
- Wikipedia: P-value
-
nGroups
public int nGroups()
Get the number of groups of observations.- Returns:
- the number of groups of observations
-
nObs
public int nObs()
Get the total number of observations.- Returns:
- the total number of observations
-
isNullRejected
public boolean isNullRejected(double alpha)
Use the p-value to check whether the null hypothesis can be rejected for a given significance level. That is, the probability of making the observations under the null is small.- Parameters:
alpha
- a significance level of test- Returns:
true
if the hypothesis is rejected due to p-value < α
-
getNullHypothesis
public abstract String getNullHypothesis()
Get a description of the null hypothesis.- Returns:
- the null hypothesis description
- See Also:
- Wikipedia: Null hypothesis
-
getAlternativeHypothesis
public abstract String getAlternativeHypothesis()
Get the description of the alternative hypothesis.- Returns:
- the alternative hypothesis description
- See Also:
- Wikipedia: Alternative hypothesis
-
oneSidedPvalue
public static double oneSidedPvalue(ProbabilityDistribution F, double x)
The one-sided p-value is the probability of observing a test statistic at least as extreme as the one observed. For a continuous distribution, it is given by the complementary cumulative distribution function (survival function). For a discrete distribution, we need to add also the probability of observing the critical value.- Parameters:
F
- a univariate distributionx
- the critical value- Returns:
- the p-value for the critical value
-
-