public class TTestImpl extends java.lang.Object implements TTest
TTest
interface.
Uses commons-math TDistributionImpl
implementation to estimate exact p-values.
Constructor and Description |
---|
TTestImpl()
Default constructor.
|
TTestImpl(TDistribution t)
Deprecated.
in 2.2 (to be removed in 3.0).
|
Modifier and Type | Method and Description |
---|---|
double |
homoscedasticT(double[] sample1,
double[] sample2)
Computes a 2-sample t statistic, under the hypothesis of equal
subpopulation variances.
|
double |
homoscedasticT(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
Computes a 2-sample 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
p-value, associated with a two-sample, two-tailed t-test
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
two-sided t-test 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. |
double |
homoscedasticTTest(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
Returns the observed significance level, or
p-value, associated with a two-sample, two-tailed t-test
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, 2-sample t-statistic based on the data in the input
arrays.
|
double |
pairedTTest(double[] sample1,
double[] sample2)
Returns the observed significance level, or
p-value, associated with a paired, two-sample, two-tailed t-test
based on the data in the input arrays.
|
boolean |
pairedTTest(double[] sample1,
double[] sample2,
double alpha)
Performs a paired t-test evaluating the null hypothesis that the
mean of the paired differences between
sample1 and
sample2 is 0 in favor of the two-sided alternative that the
mean paired difference is not equal to 0, with significance level
alpha . |
void |
setDistribution(TDistribution value)
Deprecated.
in 2.2 (to be removed in 3.0).
|
double |
t(double[] sample1,
double[] sample2)
Computes a 2-sample 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.
|
double |
t(double mu,
StatisticalSummary sampleStats)
|
double |
t(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2)
Computes a 2-sample 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
p-value, associated with a two-sample, two-tailed t-test
comparing the means of the input arrays.
|
boolean |
tTest(double[] sample1,
double[] sample2,
double alpha)
Performs a
two-sided t-test 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
p-value, associated with a one-sample, two-tailed t-test
comparing the mean of the input array with the constant
mu . |
boolean |
tTest(double mu,
double[] sample,
double alpha)
Performs a
two-sided t-test evaluating the null hypothesis that the mean of the population from
which
sample is drawn equals mu . |
double |
tTest(double mu,
StatisticalSummary sampleStats)
Returns the observed significance level, or
p-value, associated with a one-sample, two-tailed t-test
comparing the mean of the dataset described by
sampleStats
with the constant mu . |
boolean |
tTest(double mu,
StatisticalSummary sampleStats,
double alpha)
Performs a
two-sided t-test 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
p-value, associated with a two-sample, two-tailed t-test
comparing the means of the datasets described by two StatisticalSummary
instances.
|
boolean |
tTest(StatisticalSummary sampleStats1,
StatisticalSummary sampleStats2,
double alpha)
Performs a
two-sided t-test evaluating the null hypothesis that
sampleStats1 and sampleStats2 describe
datasets drawn from populations with the same mean, with significance
level alpha . |
public TTestImpl()
@Deprecated public TTestImpl(TDistribution t)
t
- distribution used to compute inference statistics.public double pairedT(double[] sample1, double[] sample2) throws java.lang.IllegalArgumentException, MathException
t(double, double[])
, with
mu = 0
and the sample array consisting of the (signed)
differences between corresponding entries in sample1
and
sample2.
Preconditions:
pairedT
in interface TTest
sample1
- array of sample data valuessample2
- array of sample data valuesjava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if the statistic can not be computed do to a
convergence or other numerical error.public double pairedTTest(double[] sample1, double[] sample2) throws java.lang.IllegalArgumentException, MathException
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 two-sided alternative that the mean paired difference is not equal to 0. For a one-sided test, divide the returned value by 2.
This test is equivalent to a one-sample t-test 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 p-value depends on the assumptions of the parametric
t-test procedure, as discussed
here
Preconditions:
pairedTTest
in interface TTest
sample1
- array of sample data valuessample2
- array of sample data valuesjava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if an error occurs computing the p-valuepublic boolean pairedTTest(double[] sample1, double[] sample2, double alpha) throws java.lang.IllegalArgumentException, MathException
sample1
and
sample2
is 0 in favor of the two-sided 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 1-sided test, use
alpha * 2
Usage Note:
The validity of the test depends on the assumptions of the parametric
t-test procedure, as discussed
here
Preconditions:
0 < alpha < 0.5
pairedTTest
in interface TTest
sample1
- array of sample data valuessample2
- array of sample data valuesalpha
- significance level of the testjava.lang.IllegalArgumentException
- if the preconditions are not metMathException
- if an error occurs performing the testpublic double t(double mu, double[] observed) throws java.lang.IllegalArgumentException
This statistic can be used to perform a one sample t-test for the mean.
Preconditions:
public double t(double mu, StatisticalSummary sampleStats) throws java.lang.IllegalArgumentException
sampleStats
to mu
.
This statistic can be used to perform a one sample t-test for the mean.
Preconditions:
observed.getN() > = 2
.
public double homoscedasticT(double[] sample1, double[] sample2) throws java.lang.IllegalArgumentException
t(double[], double[])
.
This statistic can be used to perform a (homoscedastic) two-sample t-test to compare sample means.
The t-statisitc 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) / ((n1-1) + (n2-1)))
with var1
the variance of the first sample and
var2
the variance of the second sample.
Preconditions:
homoscedasticT
in interface TTest
sample1
- array of sample data valuessample2
- array of sample data valuesjava.lang.IllegalArgumentException
- if the precondition is not metpublic double t(double[] sample1, double[] sample2) throws java.lang.IllegalArgumentException
homoscedasticT(double[], double[])
.
This statistic can be used to perform a two-sample t-test to compare sample means.
The t-statisitc 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:
public double t(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws java.lang.IllegalArgumentException
StatisticalSummary
instances, without the
assumption of equal subpopulation variances. Use
homoscedasticT(StatisticalSummary, StatisticalSummary)
to
compute a t-statistic under the equal variances assumption.
This statistic can be used to perform a two-sample t-test to compare sample means.
The returned t-statisitc 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:
public double homoscedasticT(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws java.lang.IllegalArgumentException
StatisticalSummary
instances, under the
assumption of equal subpopulation variances. To compute a t-statistic
without the equal variances assumption, use
t(StatisticalSummary, StatisticalSummary)
.
This statistic can be used to perform a (homoscedastic) two-sample t-test to compare sample means.
The t-statisitc 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) / ((n1-1) + (n2-1)))
with var1
the variance of the first sample and
var2
the variance of the second sample.
Preconditions:
homoscedasticT
in interface TTest
sampleStats1
- StatisticalSummary describing data from the first samplesampleStats2
- StatisticalSummary describing data from the second samplejava.lang.IllegalArgumentException
- if the precondition is not metpublic double tTest(double mu, double[] sample) throws java.lang.IllegalArgumentException, MathException
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 two-sided alternative that the mean
is different from mu
. For a one-sided test, divide the
returned value by 2.
Usage Note:
The validity of the test depends on the assumptions of the parametric
t-test procedure, as discussed
here
Preconditions:
tTest
in interface TTest
mu
- constant value to compare sample mean againstsample
- array of sample data valuesjava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if an error occurs computing the p-valuepublic boolean tTest(double mu, double[] sample, double alpha) throws java.lang.IllegalArgumentException, MathException
sample
is drawn equals mu
.
Returns true
iff the null hypothesis can be
rejected with confidence 1 - alpha
. To
perform a 1-sided test, use alpha * 2
Examples:
sample mean = mu
at
the 95% level, use tTest(mu, sample, 0.05)
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 one-sample
parametric t-test procedure, as discussed
here
Preconditions:
tTest
in interface TTest
mu
- constant value to compare sample mean againstsample
- array of sample data valuesalpha
- significance level of the testjava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if an error computing the p-valuepublic double tTest(double mu, StatisticalSummary sampleStats) throws java.lang.IllegalArgumentException, MathException
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 two-sided alternative that the mean
is different from mu
. For a one-sided test, divide the
returned value by 2.
Usage Note:
The validity of the test depends on the assumptions of the parametric
t-test procedure, as discussed
here
Preconditions:
tTest
in interface TTest
mu
- constant value to compare sample mean againstsampleStats
- StatisticalSummary describing sample datajava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if an error occurs computing the p-valuepublic boolean tTest(double mu, StatisticalSummary sampleStats, double alpha) throws java.lang.IllegalArgumentException, MathException
stats
is
drawn equals mu
.
Returns true
iff the null hypothesis can be rejected with
confidence 1 - alpha
. To perform a 1-sided test, use
alpha * 2.
Examples:
sample mean = mu
at
the 95% level, use tTest(mu, sampleStats, 0.05)
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 one-sample
parametric t-test procedure, as discussed
here
Preconditions:
tTest
in interface TTest
mu
- constant value to compare sample mean againstsampleStats
- StatisticalSummary describing sample data valuesalpha
- significance level of the testjava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if an error occurs computing the p-valuepublic double tTest(double[] sample1, double[] sample2) throws java.lang.IllegalArgumentException, MathException
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 two-sided alternative that they are different. For a one-sided 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 p-value. The t-statistic used is as defined in
t(double[], double[])
and the Welch-Satterthwaite 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 p-value depends on the assumptions of the parametric
t-test procedure, as discussed
here
Preconditions:
tTest
in interface TTest
sample1
- array of sample data valuessample2
- array of sample data valuesjava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if an error occurs computing the p-valuepublic double homoscedasticTTest(double[] sample1, double[] sample2) throws java.lang.IllegalArgumentException, MathException
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 two-sided alternative that they are different. For a one-sided test, divide the returned value by 2.
A pooled variance estimate is used to compute the t-statistic. 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 p-value depends on the assumptions of the parametric
t-test procedure, as discussed
here
Preconditions:
homoscedasticTTest
in interface TTest
sample1
- array of sample data valuessample2
- array of sample data valuesjava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if an error occurs computing the p-valuepublic boolean tTest(double[] sample1, double[] sample2, double alpha) throws java.lang.IllegalArgumentException, MathException
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 1-sided test, use alpha / 2
See t(double[], double[])
for the formula used to compute the
t-statistic. Degrees of freedom are approximated using the
Welch-Satterthwaite approximation.
Examples:
mean 1 = mean 2
at
the 95% level, use
tTest(sample1, sample2, 0.05).
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
t-test procedure, as discussed
here
Preconditions:
0 < alpha < 0.5
tTest
in interface TTest
sample1
- array of sample data valuessample2
- array of sample data valuesalpha
- significance level of the testjava.lang.IllegalArgumentException
- if the preconditions are not metMathException
- if an error occurs performing the testpublic boolean homoscedasticTTest(double[] sample1, double[] sample2, double alpha) throws java.lang.IllegalArgumentException, MathException
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 1-sided 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 t-statistic. See
t(double[], double[])
for the formula. The sum of the sample
sizes minus 2 is used as the degrees of freedom.
Examples:
mean 1 = mean 2
at
the 95% level, use tTest(sample1, sample2, 0.05).
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
t-test procedure, as discussed
here
Preconditions:
0 < alpha < 0.5
homoscedasticTTest
in interface TTest
sample1
- array of sample data valuessample2
- array of sample data valuesalpha
- significance level of the testjava.lang.IllegalArgumentException
- if the preconditions are not metMathException
- if an error occurs performing the testpublic double tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws java.lang.IllegalArgumentException, MathException
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 two-sided alternative that they are different. For a one-sided 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 p-value. To perform the test assuming
equal variances, use
homoscedasticTTest(StatisticalSummary, StatisticalSummary)
.
Usage Note:
The validity of the p-value depends on the assumptions of the parametric
t-test procedure, as discussed
here
Preconditions:
tTest
in interface TTest
sampleStats1
- StatisticalSummary describing data from the first samplesampleStats2
- StatisticalSummary describing data from the second samplejava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if an error occurs computing the p-valuepublic double homoscedasticTTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws java.lang.IllegalArgumentException, MathException
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 two-sided alternative that they are different. For a one-sided test, divide the returned value by 2.
See homoscedasticT(double[], double[])
for the formula used to
compute the t-statistic. The sum of the sample sizes minus 2 is used as
the degrees of freedom.
Usage Note:
The validity of the p-value depends on the assumptions of the parametric
t-test procedure, as discussed
here
Preconditions:
homoscedasticTTest
in interface TTest
sampleStats1
- StatisticalSummary describing data from the first samplesampleStats2
- StatisticalSummary describing data from the second samplejava.lang.IllegalArgumentException
- if the precondition is not metMathException
- if an error occurs computing the p-valuepublic boolean tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2, double alpha) throws java.lang.IllegalArgumentException, MathException
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 1-sided test, use alpha * 2
See t(double[], double[])
for the formula used to compute the
t-statistic. Degrees of freedom are approximated using the
Welch-Satterthwaite approximation.
Examples:
mean 1 = mean 2
at
the 95%, use
tTest(sampleStats1, sampleStats2, 0.05)
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
t-test procedure, as discussed
here
Preconditions:
0 < alpha < 0.5
tTest
in interface TTest
sampleStats1
- StatisticalSummary describing sample data valuessampleStats2
- StatisticalSummary describing sample data valuesalpha
- significance level of the testjava.lang.IllegalArgumentException
- if the preconditions are not metMathException
- if an error occurs performing the test@Deprecated public void setDistribution(TDistribution value)
value
- the new distribution"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"