Package org.apache.commons.math3.stat.inference

# Class TestUtils

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

public class TestUtils extends Object
A collection of static methods to create inference test instances or to perform inference tests.

Since:
  1.1

## Method Summary

Modifier and Type
Method
Description
`static double`
`approximateP(double d, int n, int m)`
`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 double`
`exactP(double d, int m, int n, boolean strict)`
`static double`
`g(double[] expected, long[] observed)`
`static double`
`gDataSetsComparison(long[] observed1, long[] observed2)`
`static double`
`gTest(double[] expected, long[] observed)`
`static boolean`
`gTest(double[] expected, long[] observed, double alpha)`
`static double`
`gTestDataSetsComparison(long[] observed1, long[] observed2)`
`static boolean`
`gTestDataSetsComparison(long[] observed1, long[] observed2, double alpha)`
`static double`
`gTestIntrinsic(double[] expected, long[] observed)`
`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`
`kolmogorovSmirnovStatistic(double[] x, double[] y)`
`static double`
`kolmogorovSmirnovStatistic(RealDistribution dist, double[] data)`
`static double`
`kolmogorovSmirnovTest(double[] x, double[] y)`
`static double`
`kolmogorovSmirnovTest(double[] x, double[] y, boolean strict)`
`static double`
`kolmogorovSmirnovTest(RealDistribution dist, double[] data)`
`static double`
`kolmogorovSmirnovTest(RealDistribution dist, double[] data, boolean strict)`
`static boolean`
`kolmogorovSmirnovTest(RealDistribution dist, double[] data, double alpha)`
`static double`
`monteCarloP(double d, int n, int m, boolean strict, int iterations)`
`static double`
`oneWayAnovaFValue(Collection<double[]> categoryData)`
`static double`
`oneWayAnovaPValue(Collection<double[]> categoryData)`
`static boolean`
`oneWayAnovaTest(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 double`
`rootLogLikelihoodRatio(long k11, long k12, long k21, long k22)`
`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`

## Method Details

### homoscedasticT

public static double homoscedasticT(double[] sample1, double[] sample2) throws NullArgumentException, NumberIsTooSmallException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
See Also:
  - `TTest.homoscedasticT(double[], double[])`

### homoscedasticT

public static double homoscedasticT(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws NullArgumentException, NumberIsTooSmallException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
See Also:
  - `TTest.homoscedasticT(org.apache.commons.math3.stat.descriptive.StatisticalSummary, org.apache.commons.math3.stat.descriptive.StatisticalSummary)`

### homoscedasticTTest

public static boolean homoscedasticTTest(double[] sample1, double[] sample2, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `OutOfRangeException`
  `MaxCountExceededException`
See Also:
  - `TTest.homoscedasticTTest(double[], double[], double)`

### homoscedasticTTest

public static double homoscedasticTTest(double[] sample1, double[] sample2) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `MaxCountExceededException`
See Also:
  - `TTest.homoscedasticTTest(double[], double[])`

### homoscedasticTTest

public static double homoscedasticTTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `MaxCountExceededException`
See Also:
  - `TTest.homoscedasticTTest(org.apache.commons.math3.stat.descriptive.StatisticalSummary, org.apache.commons.math3.stat.descriptive.StatisticalSummary)`

### pairedT

public static double pairedT(double[] sample1, double[] sample2) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException

Throws:
  `NullArgumentException`
  `NoDataException`
  `DimensionMismatchException`
  `NumberIsTooSmallException`
See Also:
  - `TTest.pairedT(double[], double[])`

### pairedTTest

public static boolean pairedTTest(double[] sample1, double[] sample2, double alpha) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NoDataException`
  `DimensionMismatchException`
  `NumberIsTooSmallException`
  `OutOfRangeException`
  `MaxCountExceededException`
See Also:
  - `TTest.pairedTTest(double[], double[], double)`

### pairedTTest

public static double pairedTTest(double[] sample1, double[] sample2) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NoDataException`
  `DimensionMismatchException`
  `NumberIsTooSmallException`
  `MaxCountExceededException`
See Also:
  - `TTest.pairedTTest(double[], double[])`

### t

public static double t(double mu, double[] observed) throws NullArgumentException, NumberIsTooSmallException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
See Also:
  - `TTest.t(double, double[])`

### t

public static double t(double mu, StatisticalSummary sampleStats) throws NullArgumentException, NumberIsTooSmallException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
See Also:
  - `TTest.t(double, org.apache.commons.math3.stat.descriptive.StatisticalSummary)`

### t

public static double t(double[] sample1, double[] sample2) throws NullArgumentException, NumberIsTooSmallException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
See Also:
  - `TTest.t(double[], double[])`

### t

public static double t(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws NullArgumentException, NumberIsTooSmallException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
See Also:
  - `TTest.t(org.apache.commons.math3.stat.descriptive.StatisticalSummary, org.apache.commons.math3.stat.descriptive.StatisticalSummary)`

### tTest

public static boolean tTest(double mu, double[] sample, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `OutOfRangeException`
  `MaxCountExceededException`
See Also:
  - `TTest.tTest(double, double[], double)`

### tTest

public static double tTest(double mu, double[] sample) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `MaxCountExceededException`
See Also:
  - `TTest.tTest(double, double[])`

### tTest

public static boolean tTest(double mu, StatisticalSummary sampleStats, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `OutOfRangeException`
  `MaxCountExceededException`
See Also:
  - `TTest.tTest(double, org.apache.commons.math3.stat.descriptive.StatisticalSummary, double)`

### tTest

public static double tTest(double mu, StatisticalSummary sampleStats) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `MaxCountExceededException`
See Also:
  - `TTest.tTest(double, org.apache.commons.math3.stat.descriptive.StatisticalSummary)`

### tTest

public static boolean tTest(double[] sample1, double[] sample2, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `OutOfRangeException`
  `MaxCountExceededException`
See Also:
  - `TTest.tTest(double[], double[], double)`

### tTest

public static double tTest(double[] sample1, double[] sample2) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `MaxCountExceededException`
See Also:
  - `TTest.tTest(double[], double[])`

### tTest

public static boolean tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `OutOfRangeException`
  `MaxCountExceededException`
See Also:
  - `TTest.tTest(org.apache.commons.math3.stat.descriptive.StatisticalSummary, org.apache.commons.math3.stat.descriptive.StatisticalSummary, double)`

### tTest

public static double tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `NumberIsTooSmallException`
  `MaxCountExceededException`
See Also:
  - `TTest.tTest(org.apache.commons.math3.stat.descriptive.StatisticalSummary, org.apache.commons.math3.stat.descriptive.StatisticalSummary)`

### chiSquare

public static double chiSquare(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException

Throws:
  `NotPositiveException`
  `NotStrictlyPositiveException`
  `DimensionMismatchException`
See Also:
  - `ChiSquareTest.chiSquare(double[], long[])`

### chiSquare

public static double chiSquare(long[][] counts) throws NullArgumentException, NotPositiveException, DimensionMismatchException

Throws:
  `NullArgumentException`
  `NotPositiveException`
  `DimensionMismatchException`
See Also:
  - `ChiSquareTest.chiSquare(long[][])`

### chiSquareTest

public static boolean chiSquareTest(double[] expected, long[] observed, double alpha) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, OutOfRangeException, MaxCountExceededException

Throws:
  `NotPositiveException`
  `NotStrictlyPositiveException`
  `DimensionMismatchException`
  `OutOfRangeException`
  `MaxCountExceededException`
See Also:
  - `ChiSquareTest.chiSquareTest(double[], long[], double)`

### chiSquareTest

public static double chiSquareTest(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException

Throws:
  `NotPositiveException`
  `NotStrictlyPositiveException`
  `DimensionMismatchException`
  `MaxCountExceededException`
See Also:
  - `ChiSquareTest.chiSquareTest(double[], long[])`

### chiSquareTest

public static boolean chiSquareTest(long[][] counts, double alpha) throws NullArgumentException, DimensionMismatchException, NotPositiveException, OutOfRangeException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `DimensionMismatchException`
  `NotPositiveException`
  `OutOfRangeException`
  `MaxCountExceededException`
See Also:
  - `ChiSquareTest.chiSquareTest(long[][], double)`

### chiSquareTest

public static double chiSquareTest(long[][] counts) throws NullArgumentException, DimensionMismatchException, NotPositiveException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `DimensionMismatchException`
  `NotPositiveException`
  `MaxCountExceededException`
See Also:
  - `ChiSquareTest.chiSquareTest(long[][])`

### chiSquareDataSetsComparison

public static double chiSquareDataSetsComparison(long[] observed1, long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException

Throws:
  `DimensionMismatchException`
  `NotPositiveException`
  `ZeroException`
Since:
  1.2
See Also:
  - `ChiSquareTest.chiSquareDataSetsComparison(long[], long[])`

### chiSquareTestDataSetsComparison

public static double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException, MaxCountExceededException

Throws:
  `DimensionMismatchException`
  `NotPositiveException`
  `ZeroException`
  `MaxCountExceededException`
Since:
  1.2
See Also:
  - `ChiSquareTest.chiSquareTestDataSetsComparison(long[], long[])`

### chiSquareTestDataSetsComparison

public static boolean chiSquareTestDataSetsComparison(long[] observed1, long[] observed2, double alpha) throws DimensionMismatchException, NotPositiveException, ZeroException, OutOfRangeException, MaxCountExceededException

Throws:
  `DimensionMismatchException`
  `NotPositiveException`
  `ZeroException`
  `OutOfRangeException`
  `MaxCountExceededException`
Since:
  1.2
See Also:
  - `ChiSquareTest.chiSquareTestDataSetsComparison(long[], long[], double)`

### oneWayAnovaFValue

public static double oneWayAnovaFValue(Collection<double[]> categoryData) throws NullArgumentException, DimensionMismatchException

Throws:
  `NullArgumentException`
  `DimensionMismatchException`
Since:
  1.2
See Also:
  - `OneWayAnova.anovaFValue(Collection)`

### oneWayAnovaPValue

public static double oneWayAnovaPValue(Collection<double[]> categoryData) throws NullArgumentException, DimensionMismatchException, ConvergenceException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `DimensionMismatchException`
  `ConvergenceException`
  `MaxCountExceededException`
Since:
  1.2
See Also:
  - `OneWayAnova.anovaPValue(Collection)`

### oneWayAnovaTest

public static boolean oneWayAnovaTest(Collection<double[]> categoryData, double alpha) throws NullArgumentException, DimensionMismatchException, OutOfRangeException, ConvergenceException, MaxCountExceededException

Throws:
  `NullArgumentException`
  `DimensionMismatchException`
  `OutOfRangeException`
  `ConvergenceException`
  `MaxCountExceededException`
Since:
  1.2
See Also:
  - `OneWayAnova.anovaTest(Collection,double)`

### g

public static double g(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException

Throws:
  `NotPositiveException`
  `NotStrictlyPositiveException`
  `DimensionMismatchException`
Since:
  3.1
See Also:
  - `GTest.g(double[], long[])`

### gTest

public static double gTest(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException

Throws:
  `NotPositiveException`
  `NotStrictlyPositiveException`
  `DimensionMismatchException`
  `MaxCountExceededException`
Since:
  3.1
See Also:
  - `GTest.gTest(double[], long[])`

### gTestIntrinsic

public static double gTestIntrinsic(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException

Throws:
  `NotPositiveException`
  `NotStrictlyPositiveException`
  `DimensionMismatchException`
  `MaxCountExceededException`
Since:
  3.1
See Also:
  - `GTest.gTestIntrinsic(double[], long[])`

### gTest

public static boolean gTest(double[] expected, long[] observed, double alpha) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, OutOfRangeException, MaxCountExceededException

Throws:
  `NotPositiveException`
  `NotStrictlyPositiveException`
  `DimensionMismatchException`
  `OutOfRangeException`
  `MaxCountExceededException`
Since:
  3.1
See Also:
  - `GTest.gTest(double[],long[],double)`

### gDataSetsComparison

public static double gDataSetsComparison(long[] observed1, long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException

Throws:
  `DimensionMismatchException`
  `NotPositiveException`
  `ZeroException`
Since:
  3.1
See Also:
  - `GTest.gDataSetsComparison(long[], long[])`

### rootLogLikelihoodRatio

public static double rootLogLikelihoodRatio(long k11, long k12, long k21, long k22) throws DimensionMismatchException, NotPositiveException, ZeroException

Throws:
  `DimensionMismatchException`
  `NotPositiveException`
  `ZeroException`
Since:
  3.1
See Also:
  - `GTest.rootLogLikelihoodRatio(long, long, long, long)`

### gTestDataSetsComparison

public static double gTestDataSetsComparison(long[] observed1, long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException, MaxCountExceededException

Throws:
  `DimensionMismatchException`
  `NotPositiveException`
  `ZeroException`
  `MaxCountExceededException`
Since:
  3.1
See Also:
  - `GTest.gTestDataSetsComparison(long[], long[])`

### gTestDataSetsComparison

public static boolean gTestDataSetsComparison(long[] observed1, long[] observed2, double alpha) throws DimensionMismatchException, NotPositiveException, ZeroException, OutOfRangeException, MaxCountExceededException

Throws:
  `DimensionMismatchException`
  `NotPositiveException`
  `ZeroException`
  `OutOfRangeException`
  `MaxCountExceededException`
Since:
  3.1
See Also:
  - `GTest.gTestDataSetsComparison(long[],long[],double)`

### kolmogorovSmirnovStatistic

public static double kolmogorovSmirnovStatistic(RealDistribution dist, double[] data) throws InsufficientDataException, NullArgumentException

Throws:
  `InsufficientDataException`
  `NullArgumentException`
Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.kolmogorovSmirnovStatistic(RealDistribution, double[])`

### kolmogorovSmirnovTest

public static double kolmogorovSmirnovTest(RealDistribution dist, double[] data) throws InsufficientDataException, NullArgumentException

Throws:
  `InsufficientDataException`
  `NullArgumentException`
Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.kolmogorovSmirnovTest(RealDistribution, double[])`

### kolmogorovSmirnovTest

public static double kolmogorovSmirnovTest(RealDistribution dist, double[] data, boolean strict) throws InsufficientDataException, NullArgumentException

Throws:
  `InsufficientDataException`
  `NullArgumentException`
Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.kolmogorovSmirnovTest(RealDistribution, double[], boolean)`

### kolmogorovSmirnovTest

public static boolean kolmogorovSmirnovTest(RealDistribution dist, double[] data, double alpha) throws InsufficientDataException, NullArgumentException

Throws:
  `InsufficientDataException`
  `NullArgumentException`
Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.kolmogorovSmirnovTest(RealDistribution, double[], double)`

### kolmogorovSmirnovStatistic

public static double kolmogorovSmirnovStatistic(double[] x, double[] y) throws InsufficientDataException, NullArgumentException

Throws:
  `InsufficientDataException`
  `NullArgumentException`
Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.kolmogorovSmirnovStatistic(double[], double[])`

### kolmogorovSmirnovTest

public static double kolmogorovSmirnovTest(double[] x, double[] y) throws InsufficientDataException, NullArgumentException

Throws:
  `InsufficientDataException`
  `NullArgumentException`
Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.kolmogorovSmirnovTest(double[], double[])`

### kolmogorovSmirnovTest

public static double kolmogorovSmirnovTest(double[] x, double[] y, boolean strict) throws InsufficientDataException, NullArgumentException

Throws:
  `InsufficientDataException`
  `NullArgumentException`
Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.kolmogorovSmirnovTest(double[], double[], boolean)`

### exactP

public static double exactP(double d, int m, int n, boolean strict)

Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.exactP(double, int, int, boolean)`

### approximateP

public static double approximateP(double d, int n, int m)

Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.approximateP(double, int, int)`

### monteCarloP

public static double monteCarloP(double d, int n, int m, boolean strict, int iterations)

Since:
  3.3
See Also:
  - `KolmogorovSmirnovTest.monteCarloP(double, int, int, boolean, int)`