org.apache.commons.math.stat
Interface TestStatistic

All Known Implementing Classes:
TestStatisticImpl

public interface TestStatistic

A collection of commonly used test statistics and statistical tests.

Version:
$Revision: 1.10 $ $Date: 2003/11/19 03:22:54 $

Method Summary
 double chiSquare(double[] expected, double[] observed)
          Computes the Chi-Square statistic comparing observed and expected freqeuncy counts.
 double chiSquareTest(double[] expected, double[] observed)
          Returns the observed significance level, or p-value, associated with a Chi-square goodness of fit test comparing the observed frequency counts to those in the expected array.
 boolean chiSquareTest(double[] expected, double[] observed, double alpha)
          Performs a Chi-square goodness of fit test evaluating the null hypothesis that the observed counts conform to the frequency distribution described by the expected counts, with significance level alpha.
 double t(DescriptiveStatistics sampleStats1, DescriptiveStatistics sampleStats2)
          Computes a 2-sample t statistic , comparing the datasets described by two Univariates without the assumption of equal sample variances.
 double t(double[] sample1, double[] sample2)
          Computes a 2-sample t statistic , without the assumption of equal sample variances.
 double t(double mu, DescriptiveStatistics sampleStats)
          Computes a t statistic to use in comparing the dataset described by sampleStats to mu.
 double t(double mu, double[] observed)
          Computes a t statistic given observed values and a comparison constant.
 double tTest(DescriptiveStatistics sampleStats1, DescriptiveStatistics 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 Univariates.
 boolean tTest(DescriptiveStatistics sampleStats1, DescriptiveStatistics 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.
 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, DescriptiveStatistics 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, DescriptiveStatistics 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(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.
 

Method Detail

chiSquare

public double chiSquare(double[] expected,
                        double[] observed)
                 throws IllegalArgumentException,
                        MathException
Computes the Chi-Square statistic comparing observed and expected freqeuncy counts.

This statistic can be used to perform Chi-Square tests.

Preconditions:

If any of the preconditions are not met, an IllegalArgumentException is thrown.

Parameters:
observed - array of observed frequency counts
expected - array of exptected frequency counts
Returns:
chiSquare statistic
Throws:
IllegalArgumentException - if preconditions are not met
MathException

chiSquareTest

public double chiSquareTest(double[] expected,
                            double[] observed)
                     throws IllegalArgumentException,
                            MathException
Returns the observed significance level, or p-value, associated with a Chi-square goodness of fit test comparing the observed frequency counts to those in the expected array.

The number returned is the smallest significance level at which one can reject the null hypothesis that the observed counts conform to the frequency distribution described by the expected counts.

Preconditions:

If any of the preconditions are not met, an IllegalArgumentException is thrown.

Parameters:
observed - array of observed frequency counts
expected - array of exptected frequency counts
Returns:
p-value
Throws:
IllegalArgumentException - if preconditions are not met
MathException

chiSquareTest

public boolean chiSquareTest(double[] expected,
                             double[] observed,
                             double alpha)
                      throws IllegalArgumentException,
                             MathException
Performs a Chi-square goodness of fit test evaluating the null hypothesis that the observed counts conform to the frequency distribution described by the expected counts, with significance level alpha.

Example:
To test the hypothesis that observed follows expected at the 99% level, use

chiSquareTest(expected, observed, 0.01)

Preconditions:

If any of the preconditions are not met, an IllegalArgumentException is thrown.

Parameters:
observed - array of observed frequency counts
expected - array of exptected frequency counts
alpha - significance level of the test
Returns:
true iff null hypothesis can be rejected with confidence 1 - alpha
Throws:
IllegalArgumentException - if preconditions are not met
MathException

t

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

This statistic can be used to perform a one sample t-test for the mean.

Preconditions:

Parameters:
mu - comparison constant
observed - array of values
Returns:
t statistic
Throws:
IllegalArgumentException - if input array length is less than 2
MathException

t

public double t(double[] sample1,
                double[] sample2)
         throws IllegalArgumentException,
                MathException
Computes a 2-sample t statistic , without the assumption of equal sample variances.

This statistic can be used to perform a two-sample t-test to compare sample means.

Preconditions:

Parameters:
sample1 - array of sample data values
sample2 - array of sample data values
Returns:
t statistic
Throws:
IllegalArgumentException - if the precondition is not met
MathException

tTest

public double tTest(double[] sample1,
                    double[] sample2)
             throws IllegalArgumentException,
                    MathException
Returns the observed significance level, or p-value, associated with a two-sample, two-tailed t-test 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 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 as described here

Usage Note:
The validity of the p-value depends on the assumptions of the parametric t-test procedure, as discussed here

Preconditions:

Parameters:
sample1 - array of sample data values
sample2 - array of sample data values
Returns:
p-value for t-test
Throws:
IllegalArgumentException - if the precondition is not met
MathException

tTest

public boolean tTest(double[] sample1,
                     double[] sample2,
                     double alpha)
              throws IllegalArgumentException,
                     MathException
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.

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

Examples:

  1. To test the (2-sided) hypothesis mean 1 = mean 2 at the 95% level, use
    tTest(sample1, sample2, 0.05)
  2. To test the (one-sided) 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.005)

The test does not assume that the underlying popuation variances are equal and it uses approximated degrees of freedom computed from the sample data as described here

Usage Note:
The validity of the test depends on the assumptions of the parametric t-test procedure, as discussed here

Preconditions:

Parameters:
sample1 - array of sample data values
sample2 - array of sample data values
alpha - significance level of the test
Returns:
true if the null hypothesis can be rejected with confidence 1 - alpha
Throws:
IllegalArgumentException - if the preconditions are not met
MathException

tTest

public boolean tTest(double mu,
                     double[] sample,
                     double alpha)
              throws IllegalArgumentException,
                     MathException
Performs a two-sided t-test 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 1-sided test, use alpha / 2

Examples:

  1. To test the (2-sided) hypothesis sample mean = mu at the 95% level, use
    tTest(mu, sample, 0.05)
  2. To test the (one-sided) 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.005)

Usage Note:
The validity of the test depends on the assumptions of the one-sample parametric t-test procedure, as discussed here

Preconditions:

Parameters:
mu - constant value to compare sample mean against
sample - array of sample data values
alpha - significance level of the test
Returns:
p-value
Throws:
IllegalArgumentException - if the precondition is not met
MathException

tTest

public double tTest(double mu,
                    double[] sample)
             throws IllegalArgumentException,
                    MathException
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.

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:

Parameters:
mu - constant value to compare sample mean against
sample - array of sample data values
Returns:
p-value
Throws:
IllegalArgumentException - if the precondition is not met
MathException

t

public double t(double mu,
                DescriptiveStatistics sampleStats)
         throws IllegalArgumentException,
                MathException
Computes a t statistic to use in comparing the dataset described by sampleStats to mu.

This statistic can be used to perform a one sample t-test for the mean.

Preconditions:

Parameters:
mu - comparison constant
sampleStats - DescriptiveStatistics holding sample summary statitstics
Returns:
t statistic
Throws:
IllegalArgumentException - if the precondition is not met
MathException

t

public double t(DescriptiveStatistics sampleStats1,
                DescriptiveStatistics sampleStats2)
         throws IllegalArgumentException,
                MathException
Computes a 2-sample t statistic , comparing the datasets described by two Univariates without the assumption of equal sample variances.

This statistic can be used to perform a two-sample t-test to compare sample means.

Preconditions:

Parameters:
sampleStats1 - DescriptiveStatistics describing data from the first sample
sampleStats2 - DescriptiveStatistics describing data from the second sample
Returns:
t statistic
Throws:
IllegalArgumentException - if the precondition is not met
MathException

tTest

public double tTest(DescriptiveStatistics sampleStats1,
                    DescriptiveStatistics sampleStats2)
             throws IllegalArgumentException,
                    MathException
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 Univariates.

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 as described here

Usage Note:
The validity of the p-value depends on the assumptions of the parametric t-test procedure, as discussed here

Preconditions:

Parameters:
sampleStats1 - DescriptiveStatistics describing data from the first sample
sampleStats2 - DescriptiveStatistics describing data from the second sample
Returns:
p-value for t-test
Throws:
IllegalArgumentException - if the precondition is not met
MathException

tTest

public boolean tTest(DescriptiveStatistics sampleStats1,
                     DescriptiveStatistics sampleStats2,
                     double alpha)
              throws IllegalArgumentException,
                     MathException
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.

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

Examples:

  1. To test the (2-sided) hypothesis mean 1 = mean 2 at the 95% level, use
    tTest(sampleStats1, sampleStats2, 0.05)
  2. To test the (one-sided) 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.005)

The test does not assume that the underlying popuation variances are equal and it uses approximated degrees of freedom computed from the sample data as described here

Usage Note:
The validity of the test depends on the assumptions of the parametric t-test procedure, as discussed here

Preconditions:

Parameters:
sampleStats1 - DescriptiveStatistics describing sample data values
sampleStats2 - DescriptiveStatistics describing sample data values
alpha - significance level of the test
Returns:
true if the null hypothesis can be rejected with confidence 1 - alpha
Throws:
IllegalArgumentException - if the preconditions are not met
MathException

tTest

public boolean tTest(double mu,
                     DescriptiveStatistics sampleStats,
                     double alpha)
              throws IllegalArgumentException,
                     MathException
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.

Returns true iff the null hypothesis can be rejected with confidence 1 - alpha. To perform a 1-sided test, use alpha / 2

Examples:

  1. To test the (2-sided) hypothesis sample mean = mu at the 95% level, use
    tTest(mu, sampleStats, 0.05)
  2. To test the (one-sided) 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.005)

Usage Note:
The validity of the test depends on the assumptions of the one-sample parametric t-test procedure, as discussed here

Preconditions:

Parameters:
mu - constant value to compare sample mean against
sampleStats - DescriptiveStatistics describing sample data values
alpha - significance level of the test
Returns:
p-value
Throws:
IllegalArgumentException - if the precondition is not met
MathException

tTest

public double tTest(double mu,
                    DescriptiveStatistics sampleStats)
             throws IllegalArgumentException,
                    MathException
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.

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:

Parameters:
mu - constant value to compare sample mean against
sampleStats - DescriptiveStatistics describing sample data
Returns:
p-value
Throws:
IllegalArgumentException - if the precondition is not met
MathException


Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.