Package dev.nm.stat.test.mean
Class T
- java.lang.Object
-
- dev.nm.stat.test.HypothesisTest
-
- dev.nm.stat.test.mean.T
-
public class T extends HypothesisTest
Student's t-test tests for the equality of means, for the one-sample case, against a hypothetical mean, and for two-sample case, of two populations. Welch's t-test is an adaptation of Student's t-test intended for use with two samples having possibly unequal variances. The R equivalent function ist.test
.- See Also:
- Richard D. De Veaux, Paul F. Velleman, David E. Bock. "Chapter 24," Stats: Data and Models.
- Student's t-test
- Welch's t-test
- Welch-Satterthwaite equation
-
-
Constructor Summary
Constructors Constructor Description T(double[] sample, double mu)
Construct a one-sample location test of whether the mean of a normally distributed population has a value specified in a null hypothesis.T(double[] sample1, double[] sample2)
Construct Welch's t-test, an adaptation of Student's t-test, for the use with two samples having possibly unequal variances.T(double[] sample1, double[] sample2, boolean isEqualVar, double mu)
Construct a two sample location test of the null hypothesis that the means of two normally distributed populations are equal.T(double[] sample1, double[] sample2, double mu)
Construct Welch's t-test, an adaptation of Student's t-test, for the use with two samples having possibly unequal variances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]
confidenceInterval(double confidence)
Get the confidence interval.double
df()
Get the degree of freedom.String
getAlternativeHypothesis()
Get the description of the alternative hypothesis.String
getNullHypothesis()
Get a description of the null hypothesis.double
leftConfidenceInterval(double confidence)
Get the one sided left confidence interval, [0, a]double
leftOneSidedPvalue()
Get the left, one-sided p-value.double
mean1()
Get the mean of the first sample.double
mean2()
Get the mean of the second sample.double
pValue()
Get the p-value for the test statistics.double
rightConfidenceInterval(double confidence)
Get the one sided right confidence interval, [a, ∞)double
rightOneSidedPvalue()
Get the right, one-sided p-value.double
statistics()
Get the test statistics.-
Methods inherited from class dev.nm.stat.test.HypothesisTest
isNullRejected, nGroups, nObs, oneSidedPvalue
-
-
-
-
Constructor Detail
-
T
public T(double[] sample, double mu)
Construct a one-sample location test of whether the mean of a normally distributed population has a value specified in a null hypothesis.- Parameters:
sample
- a samplemu
- the hypothetical mean in the null hypothesis
-
T
public T(double[] sample1, double[] sample2)
Construct Welch's t-test, an adaptation of Student's t-test, for the use with two samples having possibly unequal variances.- Parameters:
sample1
- sample 1sample2
- sample 2
-
T
public T(double[] sample1, double[] sample2, double mu)
Construct Welch's t-test, an adaptation of Student's t-test, for the use with two samples having possibly unequal variances.- Parameters:
sample1
- sample 1sample2
- sample 2mu
- the hypothetical mean-difference in the null hypothesis
-
T
public T(double[] sample1, double[] sample2, boolean isEqualVar, double mu)
Construct a two sample location test of the null hypothesis that the means of two normally distributed populations are equal.- Parameters:
sample1
- sample 1sample2
- sample 2isEqualVar
-true
if we assume the variances of the two samples are equal;false
otherwisemu
- the hypothetical mean-difference in the null hypothesis. The default value is 0.
-
-
Method Detail
-
getNullHypothesis
public String getNullHypothesis()
Description copied from class:HypothesisTest
Get a description of the null hypothesis.- Specified by:
getNullHypothesis
in classHypothesisTest
- Returns:
- the null hypothesis description
- See Also:
- Wikipedia: Null hypothesis
-
getAlternativeHypothesis
public String getAlternativeHypothesis()
Description copied from class:HypothesisTest
Get the description of the alternative hypothesis.- Specified by:
getAlternativeHypothesis
in classHypothesisTest
- Returns:
- the alternative hypothesis description
- See Also:
- Wikipedia: Alternative hypothesis
-
statistics
public double statistics()
Description copied from class:HypothesisTest
Get the test statistics.- Specified by:
statistics
in classHypothesisTest
- Returns:
- the test statistics
- See Also:
- Wikipedia: Test statistic
-
pValue
public double pValue()
Description copied from class:HypothesisTest
Get the p-value for the test statistics.- Specified by:
pValue
in classHypothesisTest
- Returns:
- the p-value
- See Also:
- Wikipedia: P-value
-
rightOneSidedPvalue
public double rightOneSidedPvalue()
Get the right, one-sided p-value.- Returns:
- the right, one-sided p-value.
-
leftOneSidedPvalue
public double leftOneSidedPvalue()
Get the left, one-sided p-value.- Returns:
- the left, one-sided p-value.
-
confidenceInterval
public double[] confidenceInterval(double confidence)
Get the confidence interval.- Parameters:
confidence
- the confidence level, e.g., for a 2-sided 95% confidence interval, we use 0.975 because 1 - 0.95 = 2 * (1 - 0.025)- Returns:
- the left and right interval values
-
rightConfidenceInterval
public double rightConfidenceInterval(double confidence)
Get the one sided right confidence interval, [a, ∞)- Parameters:
confidence
- the confidence level, e.g., 0.95 for 95% confidence interval- Returns:
- the left interval value
-
leftConfidenceInterval
public double leftConfidenceInterval(double confidence)
Get the one sided left confidence interval, [0, a]- Parameters:
confidence
- the confidence level, e.g., 0.95 for 95% confidence interval- Returns:
- the right interval value
-
df
public double df()
Get the degree of freedom.- Returns:
- the degree of freedom
-
mean1
public double mean1()
Get the mean of the first sample.- Returns:
- the mean of the first sample
-
mean2
public double mean2()
Get the mean of the second sample.- Returns:
- the mean of the second sample
-
-