## org.apache.commons.math.stat.inference
Class TestUtils

    java.lang.Object
      org.apache.commons.math.stat.inference.TestUtils

    public class TestUtils

extends java.lang.Object

A collection of static methods to create inference test instances or to perform inference tests.

Since:
  1.1
Version:
  $Revision: 811827 $ $Date: 2009-09-06 11:32:50 -0400 (Sun, 06 Sep 2009) $

Field Summary
`private static ChiSquareTest` `chiSquareTest` Singleton ChiSquareTest instance using default implementation.
`private static OneWayAnova` `oneWayAnova` Singleton OneWayAnova instance using default implementation.
`private static TTest` `tTest` Singleton TTest instance using default implementation.
`private static UnknownDistributionChiSquareTest` `unknownDistributionChiSquareTest` Singleton ChiSquareTest instance using default implementation.

Constructor Summary
`protected` `TestUtils()` Prevent instantiation.

Method Summary
`static double` `chiSquare(double[] expected, long[] observed)`
`static double` `chiSquare(long[][] counts)`
`static double` `chiSquareDataSetsComparison(long[] observed1, long[] observed2)`
`static double` `chiSquareTest(double[] expected, long[] observed)`
`static boolean` `chiSquareTest(double[] expected, long[] observed, double alpha)`
`static double` `chiSquareTest(long[][] counts)`
`static boolean` `chiSquareTest(long[][] counts, double alpha)`
`static double` `chiSquareTestDataSetsComparison(long[] observed1, long[] observed2)`
`static boolean` `chiSquareTestDataSetsComparison(long[] observed1, long[] observed2, double alpha)`
`static ChiSquareTest` `getChiSquareTest()` Return a (singleton) ChiSquareTest instance.
`static OneWayAnova` `getOneWayAnova()` Return a (singleton) OneWayAnova instance.
`static TTest` `getTTest()` Return a (singleton) TTest instance.
`static UnknownDistributionChiSquareTest` `getUnknownDistributionChiSquareTest()` Return a (singleton) UnknownDistributionChiSquareTest instance.
`static double` `homoscedasticT(double[] sample1, double[] sample2)`
`static double` `homoscedasticT(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)`
`static double` `homoscedasticTTest(double[] sample1, double[] sample2)`
`static boolean` `homoscedasticTTest(double[] sample1, double[] sample2, double alpha)`
`static double` `homoscedasticTTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)`
`static double` `oneWayAnovaFValue(java.util.Collection<double[]> categoryData)`
`static double` `oneWayAnovaPValue(java.util.Collection<double[]> categoryData)`
`static boolean` `oneWayAnovaTest(java.util.Collection<double[]> categoryData, double alpha)`
`static double` `pairedT(double[] sample1, double[] sample2)`
`static double` `pairedTTest(double[] sample1, double[] sample2)`
`static boolean` `pairedTTest(double[] sample1, double[] sample2, double alpha)`
`static void` `setChiSquareTest(ChiSquareTest chiSquareTest)` Set the (singleton) ChiSquareTest instance.
`static void` `setChiSquareTest(TTest chiSquareTest)` Set the (singleton) TTest instance.
`static void` `setOneWayAnova(OneWayAnova oneWayAnova)` Set the (singleton) OneWayAnova instance
`static void` `setUnknownDistributionChiSquareTest(UnknownDistributionChiSquareTest unknownDistributionChiSquareTest)` Set the (singleton) UnknownDistributionChiSquareTest instance.
`static double` `t(double[] sample1, double[] sample2)`
`static double` `t(double mu, double[] observed)`
`static double` `t(double mu, StatisticalSummary sampleStats)`
`static double` `t(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)`
`static double` `tTest(double[] sample1, double[] sample2)`
`static boolean` `tTest(double[] sample1, double[] sample2, double alpha)`
`static double` `tTest(double mu, double[] sample)`
`static boolean` `tTest(double mu, double[] sample, double alpha)`
`static double` `tTest(double mu, StatisticalSummary sampleStats)`
`static boolean` `tTest(double mu, StatisticalSummary sampleStats, double alpha)`
`static double` `tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)`
`static boolean` `tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2, double alpha)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### tTest

    private static TTest tTest

  Singleton TTest instance using default implementation.

### chiSquareTest

    private static ChiSquareTest chiSquareTest

  Singleton ChiSquareTest instance using default implementation.

### unknownDistributionChiSquareTest

    private static UnknownDistributionChiSquareTest unknownDistributionChiSquareTest

  Singleton ChiSquareTest instance using default implementation.

### oneWayAnova

    private static OneWayAnova oneWayAnova

  Singleton OneWayAnova instance using default implementation.

Constructor Detail

### TestUtils

    protected TestUtils()

  Prevent instantiation.

Method Detail

### setChiSquareTest

    public static void setChiSquareTest(TTest chiSquareTest)

  Set the (singleton) TTest instance.

  Parameters:
    `chiSquareTest` - the new instance to use
  Since:
    1.2

### getTTest

    public static TTest getTTest()

  Return a (singleton) TTest instance. Does not create a new instance.

  Returns:
    a TTest instance

### setChiSquareTest

    public static void setChiSquareTest(ChiSquareTest chiSquareTest)

  Set the (singleton) ChiSquareTest instance.

  Parameters:
    `chiSquareTest` - the new instance to use
  Since:
    1.2

### getChiSquareTest

    public static ChiSquareTest getChiSquareTest()

  Return a (singleton) ChiSquareTest instance. Does not create a new instance.

  Returns:
    a ChiSquareTest instance

### setUnknownDistributionChiSquareTest

    public static void setUnknownDistributionChiSquareTest(UnknownDistributionChiSquareTest unknownDistributionChiSquareTest)

  Set the (singleton) UnknownDistributionChiSquareTest instance.

  Parameters:
    `unknownDistributionChiSquareTest` - the new instance to use
  Since:
    1.2

### getUnknownDistributionChiSquareTest

    public static UnknownDistributionChiSquareTest getUnknownDistributionChiSquareTest()

  Return a (singleton) UnknownDistributionChiSquareTest instance. Does not create a new instance.

  Returns:
    a UnknownDistributionChiSquareTest instance

### setOneWayAnova

    public static void setOneWayAnova(OneWayAnova oneWayAnova)

  Set the (singleton) OneWayAnova instance

  Parameters:
    `oneWayAnova` - the new instance to use
  Since:
    1.2

### getOneWayAnova

    public static OneWayAnova getOneWayAnova()

  Return a (singleton) OneWayAnova instance. Does not create a new instance.

  Returns:
    a OneWayAnova instance
  Since:
    1.2

### homoscedasticT

    public static double homoscedasticT(double[] sample1,
                                        double[] sample2)
                                 throws java.lang.IllegalArgumentException

  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `TTest.homoscedasticT(double[], double[])`

### homoscedasticT

    public static double homoscedasticT(StatisticalSummary sampleStats1,
                                        StatisticalSummary sampleStats2)
                                 throws java.lang.IllegalArgumentException

  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `TTest.homoscedasticT(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)`

### homoscedasticTTest

    public static boolean homoscedasticTTest(double[] sample1,
                                             double[] sample2,
                                             double alpha)
                                      throws java.lang.IllegalArgumentException,
                                             MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.homoscedasticTTest(double[], double[], double)`

### homoscedasticTTest

    public static double homoscedasticTTest(double[] sample1,
                                            double[] sample2)
                                     throws java.lang.IllegalArgumentException,
                                            MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.homoscedasticTTest(double[], double[])`

### homoscedasticTTest

    public static double homoscedasticTTest(StatisticalSummary sampleStats1,
                                            StatisticalSummary sampleStats2)
                                     throws java.lang.IllegalArgumentException,
                                            MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.homoscedasticTTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)`

### pairedT

    public static double pairedT(double[] sample1,
                                 double[] sample2)
                          throws java.lang.IllegalArgumentException,
                                 MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.pairedT(double[], double[])`

### pairedTTest

    public static boolean pairedTTest(double[] sample1,
                                      double[] sample2,
                                      double alpha)
                               throws java.lang.IllegalArgumentException,
                                      MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.pairedTTest(double[], double[], double)`

### pairedTTest

    public static double pairedTTest(double[] sample1,
                                     double[] sample2)
                              throws java.lang.IllegalArgumentException,
                                     MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.pairedTTest(double[], double[])`

### t

    public static double t(double mu,
                           double[] observed)
                    throws java.lang.IllegalArgumentException

  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `TTest.t(double, double[])`

### t

    public static double t(double mu,
                           StatisticalSummary sampleStats)
                    throws java.lang.IllegalArgumentException

  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `TTest.t(double, org.apache.commons.math.stat.descriptive.StatisticalSummary)`

### t

    public static double t(double[] sample1,
                           double[] sample2)
                    throws java.lang.IllegalArgumentException

  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `TTest.t(double[], double[])`

### t

    public static double t(StatisticalSummary sampleStats1,
                           StatisticalSummary sampleStats2)
                    throws java.lang.IllegalArgumentException

  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `TTest.t(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)`

### tTest

    public static boolean tTest(double mu,
                                double[] sample,
                                double alpha)
                         throws java.lang.IllegalArgumentException,
                                MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.tTest(double, double[], double)`

### tTest

    public static double tTest(double mu,
                               double[] sample)
                        throws java.lang.IllegalArgumentException,
                               MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.tTest(double, double[])`

### tTest

    public static boolean tTest(double mu,
                                StatisticalSummary sampleStats,
                                double alpha)
                         throws java.lang.IllegalArgumentException,
                                MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.tTest(double, org.apache.commons.math.stat.descriptive.StatisticalSummary, double)`

### tTest

    public static double tTest(double mu,
                               StatisticalSummary sampleStats)
                        throws java.lang.IllegalArgumentException,
                               MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.tTest(double, org.apache.commons.math.stat.descriptive.StatisticalSummary)`

### tTest

    public static boolean tTest(double[] sample1,
                                double[] sample2,
                                double alpha)
                         throws java.lang.IllegalArgumentException,
                                MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.tTest(double[], double[], double)`

### tTest

    public static double tTest(double[] sample1,
                               double[] sample2)
                        throws java.lang.IllegalArgumentException,
                               MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.tTest(double[], double[])`

### tTest

    public static boolean tTest(StatisticalSummary sampleStats1,
                                StatisticalSummary sampleStats2,
                                double alpha)
                         throws java.lang.IllegalArgumentException,
                                MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.tTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary, double)`

### tTest

    public static double tTest(StatisticalSummary sampleStats1,
                               StatisticalSummary sampleStats2)
                        throws java.lang.IllegalArgumentException,
                               MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `TTest.tTest(org.apache.commons.math.stat.descriptive.StatisticalSummary, org.apache.commons.math.stat.descriptive.StatisticalSummary)`

### chiSquare

    public static double chiSquare(double[] expected,
                                   long[] observed)
                            throws java.lang.IllegalArgumentException

  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `ChiSquareTest.chiSquare(double[], long[])`

### chiSquare

    public static double chiSquare(long[][] counts)
                            throws java.lang.IllegalArgumentException

  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `ChiSquareTest.chiSquare(long[][])`

### chiSquareTest

    public static boolean chiSquareTest(double[] expected,
                                        long[] observed,
                                        double alpha)
                                 throws java.lang.IllegalArgumentException,
                                        MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `ChiSquareTest.chiSquareTest(double[], long[], double)`

### chiSquareTest

    public static double chiSquareTest(double[] expected,
                                       long[] observed)
                                throws java.lang.IllegalArgumentException,
                                       MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `ChiSquareTest.chiSquareTest(double[], long[])`

### chiSquareTest

    public static boolean chiSquareTest(long[][] counts,
                                        double alpha)
                                 throws java.lang.IllegalArgumentException,
                                        MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `ChiSquareTest.chiSquareTest(long[][], double)`

### chiSquareTest

    public static double chiSquareTest(long[][] counts)
                                throws java.lang.IllegalArgumentException,
                                       MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  See Also:
    `ChiSquareTest.chiSquareTest(long[][])`

### chiSquareDataSetsComparison

    public static double chiSquareDataSetsComparison(long[] observed1,
                                                     long[] observed2)
                                              throws java.lang.IllegalArgumentException

  Throws:
    `java.lang.IllegalArgumentException`
  Since:
    1.2
  See Also:
    `UnknownDistributionChiSquareTest.chiSquareDataSetsComparison(long[], long[])`

### chiSquareTestDataSetsComparison

    public static double chiSquareTestDataSetsComparison(long[] observed1,
                                                         long[] observed2)
                                                  throws java.lang.IllegalArgumentException,
                                                         MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  Since:
    1.2
  See Also:
    `UnknownDistributionChiSquareTest.chiSquareTestDataSetsComparison(long[], long[])`

### chiSquareTestDataSetsComparison

    public static boolean chiSquareTestDataSetsComparison(long[] observed1,
                                                          long[] observed2,
                                                          double alpha)
                                                   throws java.lang.IllegalArgumentException,
                                                          MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  Since:
    1.2
  See Also:
    `UnknownDistributionChiSquareTest.chiSquareTestDataSetsComparison(long[], long[], double)`

### oneWayAnovaFValue

    public static double oneWayAnovaFValue(java.util.Collection<double[]> categoryData)
                                    throws java.lang.IllegalArgumentException,
                                           MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  Since:
    1.2
  See Also:
    `OneWayAnova.anovaFValue(Collection)`

### oneWayAnovaPValue

    public static double oneWayAnovaPValue(java.util.Collection<double[]> categoryData)
                                    throws java.lang.IllegalArgumentException,
                                           MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  Since:
    1.2
  See Also:
    `OneWayAnova.anovaPValue(Collection)`

### oneWayAnovaTest

    public static boolean oneWayAnovaTest(java.util.Collection<double[]> categoryData,
                                          double alpha)
                                   throws java.lang.IllegalArgumentException,
                                          MathException

  Throws:
    `java.lang.IllegalArgumentException`
    `MathException`
  Since:
    1.2
  See Also:
    `OneWayAnova.anovaTest(Collection,double)`

Copyright (c) 2003-2010 Apache Software Foundation