public class TTest extends Object
Tests can be:
Test statistics are available for all tests. Methods including "Test" in
in their names perform tests, all other methods return tstatistics. Among
the "Test" methods, double
valued methods return pvalues;
boolean
valued methods perform fixed significance level tests.
Significance levels are always specified as numbers between 0 and 0.5
(e.g. tests at the 95% level use alpha=0.05
).
Input to tests can be either double[]
arrays or
StatisticalSummary
instances.
Uses commonsmath TDistribution
implementation to estimate exact pvalues.
Constructor and Description 

TTest() 
Modifier and Type  Method and Description 

protected double 
df(double v1,
double v2,
double n1,
double n2)
Computes approximate degrees of freedom for 2sample ttest.

double 
homoscedasticT(double[] sample1,
double[] sample2)
Computes a 2sample t statistic, under the hypothesis of equal
subpopulation variances.

protected double 
homoscedasticT(double m1,
double m2,
double v1,
double v2,
double n1,
double n2)
Computes t test statistic for 2sample ttest under the hypothesis
of equal subpopulation variances.

double 
homoscedasticT(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
Computes a 2sample t statistic, comparing the means of the datasets
described by two
StatisticalSummary instances, under the
assumption of equal subpopulation variances. 
double 
homoscedasticTTest(double[] sample1,
double[] sample2)
Returns the observed significance level, or
pvalue, associated with a twosample, twotailed ttest
comparing the means of the input arrays, under the assumption that
the two samples are drawn from subpopulations with equal variances.

boolean 
homoscedasticTTest(double[] sample1,
double[] sample2,
double alpha)
Performs a
twosided ttest evaluating the null hypothesis that
sample1
and sample2 are drawn from populations with the same mean,
with significance level alpha , assuming that the
subpopulation variances are equal. 
protected double 
homoscedasticTTest(double m1,
double m2,
double v1,
double v2,
double n1,
double n2)
Computes pvalue for 2sided, 2sample ttest, under the assumption
of equal subpopulation variances.

double 
homoscedasticTTest(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
Returns the observed significance level, or
pvalue, associated with a twosample, twotailed ttest
comparing the means of the datasets described by two StatisticalSummary
instances, under the hypothesis of equal subpopulation variances.

double 
pairedT(double[] sample1,
double[] sample2)
Computes a paired, 2sample tstatistic based on the data in the input
arrays.

double 
pairedTTest(double[] sample1,
double[] sample2)
Returns the observed significance level, or
pvalue, associated with a paired, twosample, twotailed ttest
based on the data in the input arrays.

boolean 
pairedTTest(double[] sample1,
double[] sample2,
double alpha)
Performs a paired ttest evaluating the null hypothesis that the
mean of the paired differences between
sample1 and
sample2 is 0 in favor of the twosided alternative that the
mean paired difference is not equal to 0, with significance level
alpha . 
double 
t(double[] sample1,
double[] sample2)
Computes a 2sample t statistic, without the hypothesis of equal
subpopulation variances.

double 
t(double mu,
double[] observed)
Computes a
t statistic given observed values and a comparison constant.

protected double 
t(double m,
double mu,
double v,
double n)
Computes t test statistic for 1sample ttest.

protected double 
t(double m1,
double m2,
double v1,
double v2,
double n1,
double n2)
Computes t test statistic for 2sample ttest.

double 
t(double mu,
StatisticalSummary sampleStats)

double 
t(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
Computes a 2sample t statistic , comparing the means of the datasets
described by two
StatisticalSummary instances, without the
assumption of equal subpopulation variances. 
double 
tTest(double[] sample1,
double[] sample2)
Returns the observed significance level, or
pvalue, associated with a twosample, twotailed ttest
comparing the means of the input arrays.

boolean 
tTest(double[] sample1,
double[] sample2,
double alpha)
Performs a
twosided ttest evaluating the null hypothesis that
sample1
and sample2 are drawn from populations with the same mean,
with significance level alpha . 
double 
tTest(double mu,
double[] sample)
Returns the observed significance level, or
pvalue, associated with a onesample, twotailed ttest
comparing the mean of the input array with the constant
mu . 
boolean 
tTest(double mu,
double[] sample,
double alpha)
Performs a
twosided ttest evaluating the null hypothesis that the mean of the population from
which
sample is drawn equals mu . 
protected double 
tTest(double m,
double mu,
double v,
double n)
Computes pvalue for 2sided, 1sample ttest.

protected double 
tTest(double m1,
double m2,
double v1,
double v2,
double n1,
double n2)
Computes pvalue for 2sided, 2sample ttest.

double 
tTest(double mu,
StatisticalSummary sampleStats)
Returns the observed significance level, or
pvalue, associated with a onesample, twotailed ttest
comparing the mean of the dataset described by
sampleStats
with the constant mu . 
boolean 
tTest(double mu,
StatisticalSummary sampleStats,
double alpha)
Performs a
twosided ttest evaluating the null hypothesis that the mean of the
population from which the dataset described by
stats is
drawn equals mu . 
double 
tTest(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
Returns the observed significance level, or
pvalue, associated with a twosample, twotailed ttest
comparing the means of the datasets described by two StatisticalSummary
instances.

boolean 
tTest(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2,
double alpha)
Performs a
twosided ttest evaluating the null hypothesis that
sampleStats1 and sampleStats2 describe
datasets drawn from populations with the same mean, with significance
level alpha . 
public double pairedT(double[] sample1, double[] sample2) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException
t(double, double[])
, with
mu = 0
and the sample array consisting of the (signed)
differences between corresponding entries in sample1
and
sample2.
Preconditions:
sample1
 array of sample data valuessample2
 array of sample data valuesNullArgumentException
 if the arrays are null
NoDataException
 if the arrays are emptyDimensionMismatchException
 if the length of the arrays is not equalNumberIsTooSmallException
 if the length of the arrays is < 2public double pairedTTest(double[] sample1, double[] sample2) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException
The number returned is the smallest significance level at which one can reject the null hypothesis that the mean of the paired differences is 0 in favor of the twosided alternative that the mean paired difference is not equal to 0. For a onesided test, divide the returned value by 2.
This test is equivalent to a onesample ttest computed using
tTest(double, double[])
with mu = 0
and the sample
array consisting of the signed differences between corresponding elements of
sample1
and sample2.
Usage Note:
The validity of the pvalue depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
sample1
 array of sample data valuessample2
 array of sample data valuesNullArgumentException
 if the arrays are null
NoDataException
 if the arrays are emptyDimensionMismatchException
 if the length of the arrays is not equalNumberIsTooSmallException
 if the length of the arrays is < 2MaxCountExceededException
 if an error occurs computing the pvaluepublic boolean pairedTTest(double[] sample1, double[] sample2, double alpha) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException
sample1
and
sample2
is 0 in favor of the twosided alternative that the
mean paired difference is not equal to 0, with significance level
alpha
.
Returns true
iff the null hypothesis can be rejected with
confidence 1  alpha
. To perform a 1sided test, use
alpha * 2
Usage Note:
The validity of the test depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
0 < alpha < 0.5
sample1
 array of sample data valuessample2
 array of sample data valuesalpha
 significance level of the testNullArgumentException
 if the arrays are null
NoDataException
 if the arrays are emptyDimensionMismatchException
 if the length of the arrays is not equalNumberIsTooSmallException
 if the length of the arrays is < 2OutOfRangeException
 if alpha
is not in the range (0, 0.5]MaxCountExceededException
 if an error occurs computing the pvaluepublic double t(double mu, double[] observed) throws NullArgumentException, NumberIsTooSmallException
This statistic can be used to perform a one sample ttest for the mean.
Preconditions:
mu
 comparison constantobserved
 array of valuesNullArgumentException
 if observed
is null
NumberIsTooSmallException
 if the length of observed
is < 2public double t(double mu, StatisticalSummary sampleStats) throws NullArgumentException, NumberIsTooSmallException
sampleStats
to mu
.
This statistic can be used to perform a one sample ttest for the mean.
Preconditions:
observed.getN() ≥ 2
.
mu
 comparison constantsampleStats
 DescriptiveStatistics holding sample summary statitsticsNullArgumentException
 if sampleStats
is null
NumberIsTooSmallException
 if the number of samples is < 2public double homoscedasticT(double[] sample1, double[] sample2) throws NullArgumentException, NumberIsTooSmallException
t(double[], double[])
.
This statistic can be used to perform a (homoscedastic) twosample ttest to compare sample means.
The tstatistic is
t = (m1  m2) / (sqrt(1/n1 +1/n2) sqrt(var))
where n1
is the size of first sample;
n2
is the size of second sample;
m1
is the mean of first sample;
m2
is the mean of second sample
var
is the pooled variance estimate:
var = sqrt(((n1  1)var1 + (n2  1)var2) / ((n11) + (n21)))
with var1
the variance of the first sample and
var2
the variance of the second sample.
Preconditions:
 The observed array lengths must both be at least 2.
 Parameters:
sample1
 array of sample data valuessample2
 array of sample data values
 Returns:
 t statistic
 Throws:
NullArgumentException
 if the arrays are null
NumberIsTooSmallException
 if the length of the arrays is < 2

t
public double t(double[] sample1,
double[] sample2)
throws NullArgumentException,
NumberIsTooSmallException
Computes a 2sample t statistic, without the hypothesis of equal
subpopulation variances. To compute a tstatistic assuming equal
variances, use homoscedasticT(double[], double[])
.
This statistic can be used to perform a twosample ttest to compare
sample means.
The tstatistic is
t = (m1  m2) / sqrt(var1/n1 + var2/n2)
where n1
is the size of the first sample
n2
is the size of the second sample;
m1
is the mean of the first sample;
m2
is the mean of the second sample;
var1
is the variance of the first sample;
var2
is the variance of the second sample;
Preconditions:
 The observed array lengths must both be at least 2.
 Parameters:
sample1
 array of sample data valuessample2
 array of sample data values
 Returns:
 t statistic
 Throws:
NullArgumentException
 if the arrays are null
NumberIsTooSmallException
 if the length of the arrays is < 2

t
public double t(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
throws NullArgumentException,
NumberIsTooSmallException
Computes a 2sample t statistic , comparing the means of the datasets
described by two StatisticalSummary
instances, without the
assumption of equal subpopulation variances. Use
homoscedasticT(StatisticalSummary, StatisticalSummary)
to
compute a tstatistic under the equal variances assumption.
This statistic can be used to perform a twosample ttest to compare
sample means.
The returned tstatistic is
t = (m1  m2) / sqrt(var1/n1 + var2/n2)
where n1
is the size of the first sample;
n2
is the size of the second sample;
m1
is the mean of the first sample;
m2
is the mean of the second sample
var1
is the variance of the first sample;
var2
is the variance of the second sample
Preconditions:
 The datasets described by the two Univariates must each contain
at least 2 observations.
 Parameters:
sampleStats1
 StatisticalSummary describing data from the first samplesampleStats2
 StatisticalSummary describing data from the second sample
 Returns:
 t statistic
 Throws:
NullArgumentException
 if the sample statistics are null
NumberIsTooSmallException
 if the number of samples is < 2

homoscedasticT
public double homoscedasticT(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
throws NullArgumentException,
NumberIsTooSmallException
Computes a 2sample t statistic, comparing the means of the datasets
described by two StatisticalSummary
instances, under the
assumption of equal subpopulation variances. To compute a tstatistic
without the equal variances assumption, use
t(StatisticalSummary, StatisticalSummary)
.
This statistic can be used to perform a (homoscedastic) twosample
ttest to compare sample means.
The tstatistic returned is
t = (m1  m2) / (sqrt(1/n1 +1/n2) sqrt(var))
where n1
is the size of first sample;
n2
is the size of second sample;
m1
is the mean of first sample;
m2
is the mean of second sample
and var
is the pooled variance estimate:
var = sqrt(((n1  1)var1 + (n2  1)var2) / ((n11) + (n21)))
with var1
the variance of the first sample and
var2
the variance of the second sample.
Preconditions:
 The datasets described by the two Univariates must each contain
at least 2 observations.
 Parameters:
sampleStats1
 StatisticalSummary describing data from the first samplesampleStats2
 StatisticalSummary describing data from the second sample
 Returns:
 t statistic
 Throws:
NullArgumentException
 if the sample statistics are null
NumberIsTooSmallException
 if the number of samples is < 2

tTest
public double tTest(double mu,
double[] sample)
throws NullArgumentException,
NumberIsTooSmallException,
MaxCountExceededException
Returns the observed significance level, or
pvalue, associated with a onesample, twotailed ttest
comparing the mean of the input array with the constant mu
.
The number returned is the smallest significance level
at which one can reject the null hypothesis that the mean equals
mu
in favor of the twosided alternative that the mean
is different from mu
. For a onesided test, divide the
returned value by 2.
Usage Note:
The validity of the test depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
 The observed array length must be at least 2.
 Parameters:
mu
 constant value to compare sample mean againstsample
 array of sample data values
 Returns:
 pvalue
 Throws:
NullArgumentException
 if the sample array is null
NumberIsTooSmallException
 if the length of the array is < 2
MaxCountExceededException
 if an error occurs computing the pvalue

tTest
public boolean tTest(double mu,
double[] sample,
double alpha)
throws NullArgumentException,
NumberIsTooSmallException,
OutOfRangeException,
MaxCountExceededException
Performs a
twosided ttest evaluating the null hypothesis that the mean of the population from
which sample
is drawn equals mu
.
Returns true
iff the null hypothesis can be
rejected with confidence 1  alpha
. To
perform a 1sided test, use alpha * 2
Examples:
 To test the (2sided) hypothesis
sample mean = mu
at
the 95% level, use
tTest(mu, sample, 0.05)
 To test the (onesided) hypothesis
sample mean < mu
at the 99% level, first verify that the measured sample mean is less
than mu
and then use
tTest(mu, sample, 0.02)
Usage Note:
The validity of the test depends on the assumptions of the onesample
parametric ttest procedure, as discussed
here
Preconditions:
 The observed array length must be at least 2.
 Parameters:
mu
 constant value to compare sample mean againstsample
 array of sample data valuesalpha
 significance level of the test
 Returns:
 pvalue
 Throws:
NullArgumentException
 if the sample array is null
NumberIsTooSmallException
 if the length of the array is < 2
OutOfRangeException
 if alpha
is not in the range (0, 0.5]
MaxCountExceededException
 if an error computing the pvalue

tTest
public double tTest(double mu,
StatisticalSummary sampleStats)
throws NullArgumentException,
NumberIsTooSmallException,
MaxCountExceededException
Returns the observed significance level, or
pvalue, associated with a onesample, twotailed ttest
comparing the mean of the dataset described by sampleStats
with the constant mu
.
The number returned is the smallest significance level
at which one can reject the null hypothesis that the mean equals
mu
in favor of the twosided alternative that the mean
is different from mu
. For a onesided test, divide the
returned value by 2.
Usage Note:
The validity of the test depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
 The sample must contain at least 2 observations.
 Parameters:
mu
 constant value to compare sample mean againstsampleStats
 StatisticalSummary describing sample data
 Returns:
 pvalue
 Throws:
NullArgumentException
 if sampleStats
is null
NumberIsTooSmallException
 if the number of samples is < 2
MaxCountExceededException
 if an error occurs computing the pvalue

tTest
public boolean tTest(double mu,
StatisticalSummary sampleStats,
double alpha)
throws NullArgumentException,
NumberIsTooSmallException,
OutOfRangeException,
MaxCountExceededException
Performs a
twosided ttest evaluating the null hypothesis that the mean of the
population from which the dataset described by stats
is
drawn equals mu
.
Returns true
iff the null hypothesis can be rejected with
confidence 1  alpha
. To perform a 1sided test, use
alpha * 2.
Examples:
 To test the (2sided) hypothesis
sample mean = mu
at
the 95% level, use
tTest(mu, sampleStats, 0.05)
 To test the (onesided) hypothesis
sample mean < mu
at the 99% level, first verify that the measured sample mean is less
than mu
and then use
tTest(mu, sampleStats, 0.02)
Usage Note:
The validity of the test depends on the assumptions of the onesample
parametric ttest procedure, as discussed
here
Preconditions:
 The sample must include at least 2 observations.
 Parameters:
mu
 constant value to compare sample mean againstsampleStats
 StatisticalSummary describing sample data valuesalpha
 significance level of the test
 Returns:
 pvalue
 Throws:
NullArgumentException
 if sampleStats
is null
NumberIsTooSmallException
 if the number of samples is < 2
OutOfRangeException
 if alpha
is not in the range (0, 0.5]
MaxCountExceededException
 if an error occurs computing the pvalue

tTest
public double tTest(double[] sample1,
double[] sample2)
throws NullArgumentException,
NumberIsTooSmallException,
MaxCountExceededException
Returns the observed significance level, or
pvalue, associated with a twosample, twotailed ttest
comparing the means of the input arrays.
The number returned is the smallest significance level
at which one can reject the null hypothesis that the two means are
equal in favor of the twosided alternative that they are different.
For a onesided test, divide the returned value by 2.
The test does not assume that the underlying popuation variances are
equal and it uses approximated degrees of freedom computed from the
sample data to compute the pvalue. The tstatistic used is as defined in
t(double[], double[])
and the WelchSatterthwaite approximation
to the degrees of freedom is used,
as described
here. To perform the test under the assumption of equal subpopulation
variances, use homoscedasticTTest(double[], double[])
.
Usage Note:
The validity of the pvalue depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
 The observed array lengths must both be at least 2.
 Parameters:
sample1
 array of sample data valuessample2
 array of sample data values
 Returns:
 pvalue for ttest
 Throws:
NullArgumentException
 if the arrays are null
NumberIsTooSmallException
 if the length of the arrays is < 2
MaxCountExceededException
 if an error occurs computing the pvalue

homoscedasticTTest
public double homoscedasticTTest(double[] sample1,
double[] sample2)
throws NullArgumentException,
NumberIsTooSmallException,
MaxCountExceededException
Returns the observed significance level, or
pvalue, associated with a twosample, twotailed ttest
comparing the means of the input arrays, under the assumption that
the two samples are drawn from subpopulations with equal variances.
To perform the test without the equal variances assumption, use
tTest(double[], double[])
.
The number returned is the smallest significance level
at which one can reject the null hypothesis that the two means are
equal in favor of the twosided alternative that they are different.
For a onesided test, divide the returned value by 2.
A pooled variance estimate is used to compute the tstatistic. See
homoscedasticT(double[], double[])
. The sum of the sample sizes
minus 2 is used as the degrees of freedom.
Usage Note:
The validity of the pvalue depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
 The observed array lengths must both be at least 2.
 Parameters:
sample1
 array of sample data valuessample2
 array of sample data values
 Returns:
 pvalue for ttest
 Throws:
NullArgumentException
 if the arrays are null
NumberIsTooSmallException
 if the length of the arrays is < 2
MaxCountExceededException
 if an error occurs computing the pvalue

tTest
public boolean tTest(double[] sample1,
double[] sample2,
double alpha)
throws NullArgumentException,
NumberIsTooSmallException,
OutOfRangeException,
MaxCountExceededException
Performs a
twosided ttest evaluating the null hypothesis that sample1
and sample2
are drawn from populations with the same mean,
with significance level alpha
. This test does not assume
that the subpopulation variances are equal. To perform the test assuming
equal variances, use
homoscedasticTTest(double[], double[], double)
.
Returns true
iff the null hypothesis that the means are
equal can be rejected with confidence 1  alpha
. To
perform a 1sided test, use alpha * 2
See t(double[], double[])
for the formula used to compute the
tstatistic. Degrees of freedom are approximated using the
WelchSatterthwaite approximation.
Examples:
 To test the (2sided) hypothesis
mean 1 = mean 2
at
the 95% level, use
tTest(sample1, sample2, 0.05).
 To test the (onesided) hypothesis
mean 1 < mean 2
,
at the 99% level, first verify that the measured mean of sample 1
is less than the mean of sample 2
and then use
tTest(sample1, sample2, 0.02)
Usage Note:
The validity of the test depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
 The observed array lengths must both be at least 2.

0 < alpha < 0.5
 Parameters:
sample1
 array of sample data valuessample2
 array of sample data valuesalpha
 significance level of the test
 Returns:
 true if the null hypothesis can be rejected with
confidence 1  alpha
 Throws:
NullArgumentException
 if the arrays are null
NumberIsTooSmallException
 if the length of the arrays is < 2
OutOfRangeException
 if alpha
is not in the range (0, 0.5]
MaxCountExceededException
 if an error occurs computing the pvalue

homoscedasticTTest
public boolean homoscedasticTTest(double[] sample1,
double[] sample2,
double alpha)
throws NullArgumentException,
NumberIsTooSmallException,
OutOfRangeException,
MaxCountExceededException
Performs a
twosided ttest evaluating the null hypothesis that sample1
and sample2
are drawn from populations with the same mean,
with significance level alpha
, assuming that the
subpopulation variances are equal. Use
tTest(double[], double[], double)
to perform the test without
the assumption of equal variances.
Returns true
iff the null hypothesis that the means are
equal can be rejected with confidence 1  alpha
. To
perform a 1sided test, use alpha * 2.
To perform the test
without the assumption of equal subpopulation variances, use
tTest(double[], double[], double)
.
A pooled variance estimate is used to compute the tstatistic. See
t(double[], double[])
for the formula. The sum of the sample
sizes minus 2 is used as the degrees of freedom.
Examples:
 To test the (2sided) hypothesis
mean 1 = mean 2
at
the 95% level, use
tTest(sample1, sample2, 0.05).
 To test the (onesided) hypothesis
mean 1 < mean 2,
at the 99% level, first verify that the measured mean of
sample 1
is less than the mean of sample 2
and then use
tTest(sample1, sample2, 0.02)
Usage Note:
The validity of the test depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
 The observed array lengths must both be at least 2.

0 < alpha < 0.5
 Parameters:
sample1
 array of sample data valuessample2
 array of sample data valuesalpha
 significance level of the test
 Returns:
 true if the null hypothesis can be rejected with
confidence 1  alpha
 Throws:
NullArgumentException
 if the arrays are null
NumberIsTooSmallException
 if the length of the arrays is < 2
OutOfRangeException
 if alpha
is not in the range (0, 0.5]
MaxCountExceededException
 if an error occurs computing the pvalue

tTest
public double tTest(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
throws NullArgumentException,
NumberIsTooSmallException,
MaxCountExceededException
Returns the observed significance level, or
pvalue, associated with a twosample, twotailed ttest
comparing the means of the datasets described by two StatisticalSummary
instances.
The number returned is the smallest significance level
at which one can reject the null hypothesis that the two means are
equal in favor of the twosided alternative that they are different.
For a onesided test, divide the returned value by 2.
The test does not assume that the underlying population variances are
equal and it uses approximated degrees of freedom computed from the
sample data to compute the pvalue. To perform the test assuming
equal variances, use
homoscedasticTTest(StatisticalSummary, StatisticalSummary)
.
Usage Note:
The validity of the pvalue depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
 The datasets described by the two Univariates must each contain
at least 2 observations.
 Parameters:
sampleStats1
 StatisticalSummary describing data from the first samplesampleStats2
 StatisticalSummary describing data from the second sample
 Returns:
 pvalue for ttest
 Throws:
NullArgumentException
 if the sample statistics are null
NumberIsTooSmallException
 if the number of samples is < 2
MaxCountExceededException
 if an error occurs computing the pvalue

homoscedasticTTest
public double homoscedasticTTest(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
throws NullArgumentException,
NumberIsTooSmallException,
MaxCountExceededException
Returns the observed significance level, or
pvalue, associated with a twosample, twotailed ttest
comparing the means of the datasets described by two StatisticalSummary
instances, under the hypothesis of equal subpopulation variances. To
perform a test without the equal variances assumption, use
tTest(StatisticalSummary, StatisticalSummary)
.
The number returned is the smallest significance level
at which one can reject the null hypothesis that the two means are
equal in favor of the twosided alternative that they are different.
For a onesided test, divide the returned value by 2.
See homoscedasticT(double[], double[])
for the formula used to
compute the tstatistic. The sum of the sample sizes minus 2 is used as
the degrees of freedom.
Usage Note:
The validity of the pvalue depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
 The datasets described by the two Univariates must each contain
at least 2 observations.
 Parameters:
sampleStats1
 StatisticalSummary describing data from the first samplesampleStats2
 StatisticalSummary describing data from the second sample
 Returns:
 pvalue for ttest
 Throws:
NullArgumentException
 if the sample statistics are null
NumberIsTooSmallException
 if the number of samples is < 2
MaxCountExceededException
 if an error occurs computing the pvalue

tTest
public boolean tTest(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2,
double alpha)
throws NullArgumentException,
NumberIsTooSmallException,
OutOfRangeException,
MaxCountExceededException
Performs a
twosided ttest evaluating the null hypothesis that
sampleStats1
and sampleStats2
describe
datasets drawn from populations with the same mean, with significance
level alpha
. This test does not assume that the
subpopulation variances are equal. To perform the test under the equal
variances assumption, use
homoscedasticTTest(StatisticalSummary, StatisticalSummary)
.
Returns true
iff the null hypothesis that the means are
equal can be rejected with confidence 1  alpha
. To
perform a 1sided test, use alpha * 2
See t(double[], double[])
for the formula used to compute the
tstatistic. Degrees of freedom are approximated using the
WelchSatterthwaite approximation.
Examples:
 To test the (2sided) hypothesis
mean 1 = mean 2
at
the 95%, use
tTest(sampleStats1, sampleStats2, 0.05)
 To test the (onesided) hypothesis
mean 1 < mean 2
at the 99% level, first verify that the measured mean of
sample 1
is less than the mean of sample 2
and then use
tTest(sampleStats1, sampleStats2, 0.02)
Usage Note:
The validity of the test depends on the assumptions of the parametric
ttest procedure, as discussed
here
Preconditions:
 The datasets described by the two Univariates must each contain
at least 2 observations.

0 < alpha < 0.5
 Parameters:
sampleStats1
 StatisticalSummary describing sample data valuessampleStats2
 StatisticalSummary describing sample data valuesalpha
 significance level of the test
 Returns:
 true if the null hypothesis can be rejected with
confidence 1  alpha
 Throws:
NullArgumentException
 if the sample statistics are null
NumberIsTooSmallException
 if the number of samples is < 2
OutOfRangeException
 if alpha
is not in the range (0, 0.5]
MaxCountExceededException
 if an error occurs computing the pvalue

df
protected double df(double v1,
double v2,
double n1,
double n2)
Computes approximate degrees of freedom for 2sample ttest.
 Parameters:
v1
 first sample variancev2
 second sample variancen1
 first sample nn2
 second sample n
 Returns:
 approximate degrees of freedom

t
protected double t(double m,
double mu,
double v,
double n)
Computes t test statistic for 1sample ttest.
 Parameters:
m
 sample meanmu
 constant to test againstv
 sample variancen
 sample n
 Returns:
 t test statistic

t
protected double t(double m1,
double m2,
double v1,
double v2,
double n1,
double n2)
Computes t test statistic for 2sample ttest.
Does not assume that subpopulation variances are equal.
 Parameters:
m1
 first sample meanm2
 second sample meanv1
 first sample variancev2
 second sample variancen1
 first sample nn2
 second sample n
 Returns:
 t test statistic

homoscedasticT
protected double homoscedasticT(double m1,
double m2,
double v1,
double v2,
double n1,
double n2)
Computes t test statistic for 2sample ttest under the hypothesis
of equal subpopulation variances.
 Parameters:
m1
 first sample meanm2
 second sample meanv1
 first sample variancev2
 second sample variancen1
 first sample nn2
 second sample n
 Returns:
 t test statistic

tTest
protected double tTest(double m,
double mu,
double v,
double n)
throws MaxCountExceededException
Computes pvalue for 2sided, 1sample ttest.
 Parameters:
m
 sample meanmu
 constant to test againstv
 sample variancen
 sample n
 Returns:
 pvalue
 Throws:
MaxCountExceededException
 if an error occurs computing the pvalue

tTest
protected double tTest(double m1,
double m2,
double v1,
double v2,
double n1,
double n2)
throws MaxCountExceededException
Computes pvalue for 2sided, 2sample ttest.
Does not assume subpopulation variances are equal. Degrees of freedom
are estimated from the data.
 Parameters:
m1
 first sample meanm2
 second sample meanv1
 first sample variancev2
 second sample variancen1
 first sample nn2
 second sample n
 Returns:
 pvalue
 Throws:
MaxCountExceededException
 if an error occurs computing the pvalue

homoscedasticTTest
protected double homoscedasticTTest(double m1,
double m2,
double v1,
double v2,
double n1,
double n2)
throws MaxCountExceededException
Computes pvalue for 2sided, 2sample ttest, under the assumption
of equal subpopulation variances.
The sum of the sample sizes minus 2 is used as degrees of freedom.
 Parameters:
m1
 first sample meanm2
 second sample meanv1
 first sample variancev2
 second sample variancen1
 first sample nn2
 second sample n
 Returns:
 pvalue
 Throws:
MaxCountExceededException
 if an error occurs computing the pvalue
Copyright © 20032012 The Apache Software Foundation. All Rights Reserved.