SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.test.mean
Class T

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.test.HypothesisTest
      extended by com.numericalmethod.suanshu.stats.test.mean.T

public class T
extends HypothesisTest

Student's TDistribution-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 is t.test.

See Also:

Field Summary
 double df
          degree of freedom
 double mean1
          mean for sample 1
 double mean2
          mean for sample 2
 double pValue1SidedGreater
          right, one-sided p-value
 double pValue1SidedLess
          left, one-sided p-value
 UnivariateDistribution T
          the associated TDistribution distribution
 double var1
          variance for sample 1
 double var2
          variance for sample 2
 
Fields inherited from class com.numericalmethod.suanshu.stats.test.HypothesisTest
k, N, pValue, testStatistics
 
Constructor Summary
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
 java.lang.String alternativeHypothesis()
          Get a description of the alternative hypothesis.
 double[] confidenceInterval(double confidence)
          Compute the confidence interval.
 double leftConfidenceInterval(double confidence)
          Compute the one sided left confidence interval, [0, a]
 java.lang.String nullHypothesis()
          Get a description of the null hypothesis.
 double rightConfidenceInterval(double confidence)
          Compute the one sided right confidence interval, [a, ∞)
 
Methods inherited from class com.numericalmethod.suanshu.stats.test.HypothesisTest
oneSidedPvalue, pValue, rejectNull, testStatistics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

df

public final double df
degree of freedom


mean1

public final double mean1
mean for sample 1


var1

public final double var1
variance for sample 1


mean2

public final double mean2
mean for sample 2


var2

public final double var2
variance for sample 2


pValue1SidedLess

public final double pValue1SidedLess
left, one-sided p-value


pValue1SidedGreater

public final double pValue1SidedGreater
right, one-sided p-value


T

public final UnivariateDistribution T
the associated TDistribution distribution

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 - sample
mu - 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 1
sample2 - 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 1
sample2 - sample 2
mu - 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 1
sample2 - sample 2
isEqualVar - true if we assume the variances of the two samples are equal; false otherwise
mu - the hypothetical mean-difference in the null hypothesis. Default value is 0.
Method Detail

nullHypothesis

public java.lang.String nullHypothesis()
Description copied from class: HypothesisTest
Get a description of the null hypothesis.

Specified by:
nullHypothesis in class HypothesisTest
Returns:
the null hypothesis description
See Also:
Wikipedia: Null hypothesis

alternativeHypothesis

public java.lang.String alternativeHypothesis()
Description copied from class: HypothesisTest
Get a description of the alternative hypothesis.

Specified by:
alternativeHypothesis in class HypothesisTest
Returns:
the alternative hypothesis description
See Also:
Wikipedia: Alternative hypothesis

confidenceInterval

public double[] confidenceInterval(double confidence)
Compute 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)
Compute 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)
Compute 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

SuanShu, a Java numerical and statistical library

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