Class InferenceTestUtils
- java.lang.Object
-
- org.apache.commons.math4.legacy.stat.inference.InferenceTestUtils
-
public final class InferenceTestUtils extends Object
A collection of static methods to create inference test instances or to perform inference tests.- Since:
- 1.1
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubleapproximateP(double d, int n, int m)static doublechiSquare(double[] expected, long[] observed)static doublechiSquare(long[][] counts)static doublechiSquareDataSetsComparison(long[] observed1, long[] observed2)static doublechiSquareTest(double[] expected, long[] observed)static booleanchiSquareTest(double[] expected, long[] observed, double alpha)static doublechiSquareTest(long[][] counts)static booleanchiSquareTest(long[][] counts, double alpha)static doublechiSquareTestDataSetsComparison(long[] observed1, long[] observed2)static booleanchiSquareTestDataSetsComparison(long[] observed1, long[] observed2, double alpha)static doubleexactP(double d, int m, int n, boolean strict)static doubleg(double[] expected, long[] observed)static doublegDataSetsComparison(long[] observed1, long[] observed2)static doublegTest(double[] expected, long[] observed)static booleangTest(double[] expected, long[] observed, double alpha)static doublegTestDataSetsComparison(long[] observed1, long[] observed2)static booleangTestDataSetsComparison(long[] observed1, long[] observed2, double alpha)static doublegTestIntrinsic(double[] expected, long[] observed)static doublehomoscedasticT(double[] sample1, double[] sample2)static doublehomoscedasticT(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)static doublehomoscedasticTTest(double[] sample1, double[] sample2)static booleanhomoscedasticTTest(double[] sample1, double[] sample2, double alpha)static doublehomoscedasticTTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)static doublekolmogorovSmirnovStatistic(double[] x, double[] y)static doublekolmogorovSmirnovStatistic(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data)static doublekolmogorovSmirnovTest(double[] x, double[] y)static doublekolmogorovSmirnovTest(double[] x, double[] y, boolean strict)static doublekolmogorovSmirnovTest(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data)static doublekolmogorovSmirnovTest(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data, boolean strict)static booleankolmogorovSmirnovTest(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data, double alpha)static doublemonteCarloP(double d, int n, int m, boolean strict, int iterations, org.apache.commons.rng.UniformRandomProvider rng)static doubleoneWayAnovaFValue(Collection<double[]> categoryData)static doubleoneWayAnovaPValue(Collection<double[]> categoryData)static booleanoneWayAnovaTest(Collection<double[]> categoryData, double alpha)static doublepairedT(double[] sample1, double[] sample2)static doublepairedTTest(double[] sample1, double[] sample2)static booleanpairedTTest(double[] sample1, double[] sample2, double alpha)static doublerootLogLikelihoodRatio(long k11, long k12, long k21, long k22)static doublet(double[] sample1, double[] sample2)static doublet(double mu, double[] observed)static doublet(double mu, StatisticalSummary sampleStats)static doublet(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)static doubletTest(double[] sample1, double[] sample2)static booleantTest(double[] sample1, double[] sample2, double alpha)static doubletTest(double mu, double[] sample)static booleantTest(double mu, double[] sample, double alpha)static doubletTest(double mu, StatisticalSummary sampleStats)static booleantTest(double mu, StatisticalSummary sampleStats, double alpha)static doubletTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2)static booleantTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2, double alpha)
-
-
-
Method Detail
-
homoscedasticT
public static double homoscedasticT(double[] sample1, double[] sample2) throws NullArgumentException, NumberIsTooSmallException
- Parameters:
sample1- array of sample data valuessample2- array of sample data values- Returns:
- t statistic
- Throws:
NullArgumentExceptionNumberIsTooSmallException- See Also:
TTest.homoscedasticT(double[], double[])
-
homoscedasticT
public static double homoscedasticT(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws NullArgumentException, NumberIsTooSmallException
- Parameters:
sampleStats1- StatisticalSummary describing data from the first samplesampleStats2- StatisticalSummary describing data from the second sample- Returns:
- t statistic
- Throws:
NullArgumentExceptionNumberIsTooSmallException- See Also:
TTest.homoscedasticT(org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary, org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary)
-
homoscedasticTTest
public static boolean homoscedasticTTest(double[] sample1, double[] sample2, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException
- 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:
NullArgumentExceptionNumberIsTooSmallExceptionOutOfRangeExceptionMaxCountExceededException- See Also:
TTest.homoscedasticTTest(double[], double[], double)
-
homoscedasticTTest
public static double homoscedasticTTest(double[] sample1, double[] sample2) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException
- Parameters:
sample1- array of sample data valuessample2- array of sample data values- Returns:
- p-value for t-test
- Throws:
NullArgumentExceptionNumberIsTooSmallExceptionMaxCountExceededException- See Also:
TTest.homoscedasticTTest(double[], double[])
-
homoscedasticTTest
public static double homoscedasticTTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException
- Parameters:
sampleStats1- StatisticalSummary describing data from the first samplesampleStats2- StatisticalSummary describing data from the second sample- Returns:
- p-value for t-test
- Throws:
NullArgumentExceptionNumberIsTooSmallExceptionMaxCountExceededException- See Also:
TTest.homoscedasticTTest(org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary, org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary)
-
pairedT
public static double pairedT(double[] sample1, double[] sample2) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException
- Parameters:
sample1- array of sample data valuessample2- array of sample data values- Returns:
- t statistic
- Throws:
NullArgumentExceptionNoDataExceptionDimensionMismatchExceptionNumberIsTooSmallException- See Also:
TTest.pairedT(double[], double[])
-
pairedTTest
public static boolean pairedTTest(double[] sample1, double[] sample2, double alpha) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException
- 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:
NullArgumentExceptionNoDataExceptionDimensionMismatchExceptionNumberIsTooSmallExceptionOutOfRangeExceptionMaxCountExceededException- See Also:
TTest.pairedTTest(double[], double[], double)
-
pairedTTest
public static double pairedTTest(double[] sample1, double[] sample2) throws NullArgumentException, NoDataException, DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException
- Parameters:
sample1- array of sample data valuessample2- array of sample data values- Returns:
- p-value for t-test
- Throws:
NullArgumentExceptionNoDataExceptionDimensionMismatchExceptionNumberIsTooSmallExceptionMaxCountExceededException- See Also:
TTest.pairedTTest(double[], double[])
-
t
public static double t(double mu, double[] observed) throws NullArgumentException, NumberIsTooSmallException
- Parameters:
mu- comparison constantobserved- array of values- Returns:
- t statistic
- Throws:
NullArgumentExceptionNumberIsTooSmallException- See Also:
TTest.t(double, double[])
-
t
public static double t(double mu, StatisticalSummary sampleStats) throws NullArgumentException, NumberIsTooSmallException
- Parameters:
mu- comparison constantsampleStats- DescriptiveStatistics holding sample summary statitstics- Returns:
- t statistic
- Throws:
NullArgumentExceptionNumberIsTooSmallException- See Also:
TTest.t(double, org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary)
-
t
public static double t(double[] sample1, double[] sample2) throws NullArgumentException, NumberIsTooSmallException
- Parameters:
sample1- array of sample data valuessample2- array of sample data values- Returns:
- t statistic
- Throws:
NullArgumentExceptionNumberIsTooSmallException- See Also:
TTest.t(double[], double[])
-
t
public static double t(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws NullArgumentException, NumberIsTooSmallException
- Parameters:
sampleStats1- StatisticalSummary describing data from the first samplesampleStats2- StatisticalSummary describing data from the second sample- Returns:
- t statistic
- Throws:
NullArgumentExceptionNumberIsTooSmallException- See Also:
TTest.t(org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary, org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary)
-
tTest
public static boolean tTest(double mu, double[] sample, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException
- Parameters:
mu- constant value to compare sample mean againstsample- array of sample data valuesalpha- significance level of the test- Returns:
- p-value
- Throws:
NullArgumentExceptionNumberIsTooSmallExceptionOutOfRangeExceptionMaxCountExceededException- See Also:
TTest.tTest(double, double[], double)
-
tTest
public static double tTest(double mu, double[] sample) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException
- Parameters:
mu- constant value to compare sample mean againstsample- array of sample data values- Returns:
- p-value
- Throws:
NullArgumentExceptionNumberIsTooSmallExceptionMaxCountExceededException- See Also:
TTest.tTest(double, double[])
-
tTest
public static boolean tTest(double mu, StatisticalSummary sampleStats, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException
- Parameters:
mu- constant value to compare sample mean againstsampleStats- StatisticalSummary describing sample data valuesalpha- significance level of the test- Returns:
- p-value
- Throws:
NullArgumentExceptionNumberIsTooSmallExceptionOutOfRangeExceptionMaxCountExceededException- See Also:
TTest.tTest(double, org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary, double)
-
tTest
public static double tTest(double mu, StatisticalSummary sampleStats) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException
- Parameters:
mu- constant value to compare sample mean againstsampleStats- StatisticalSummary describing sample data- Returns:
- p-value
- Throws:
NullArgumentExceptionNumberIsTooSmallExceptionMaxCountExceededException- See Also:
TTest.tTest(double, org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary)
-
tTest
public static boolean tTest(double[] sample1, double[] sample2, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException
- 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:
NullArgumentExceptionNumberIsTooSmallExceptionOutOfRangeExceptionMaxCountExceededException- See Also:
TTest.tTest(double[], double[], double)
-
tTest
public static double tTest(double[] sample1, double[] sample2) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException
- Parameters:
sample1- array of sample data valuessample2- array of sample data values- Returns:
- p-value for t-test
- Throws:
NullArgumentExceptionNumberIsTooSmallExceptionMaxCountExceededException- See Also:
TTest.tTest(double[], double[])
-
tTest
public static boolean tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2, double alpha) throws NullArgumentException, NumberIsTooSmallException, OutOfRangeException, MaxCountExceededException
- 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:
NullArgumentExceptionNumberIsTooSmallExceptionOutOfRangeExceptionMaxCountExceededException- See Also:
TTest.tTest(org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary, org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary, double)
-
tTest
public static double tTest(StatisticalSummary sampleStats1, StatisticalSummary sampleStats2) throws NullArgumentException, NumberIsTooSmallException, MaxCountExceededException
- Parameters:
sampleStats1- StatisticalSummary describing data from the first samplesampleStats2- StatisticalSummary describing data from the second sample- Returns:
- p-value for t-test
- Throws:
NullArgumentExceptionNumberIsTooSmallExceptionMaxCountExceededException- See Also:
TTest.tTest(org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary, org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary)
-
chiSquare
public static double chiSquare(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException
- Parameters:
observed- array of observed frequency countsexpected- array of expected frequency counts- Returns:
- chiSquare test statistic
- Throws:
NotPositiveExceptionNotStrictlyPositiveExceptionDimensionMismatchException- See Also:
ChiSquareTest.chiSquare(double[], long[])
-
chiSquare
public static double chiSquare(long[][] counts) throws NullArgumentException, NotPositiveException, DimensionMismatchException
- Parameters:
counts- array representation of 2-way table- Returns:
- chiSquare test statistic
- Throws:
NullArgumentExceptionNotPositiveExceptionDimensionMismatchException- See Also:
ChiSquareTest.chiSquare(long[][])
-
chiSquareTest
public static boolean chiSquareTest(double[] expected, long[] observed, double alpha) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, OutOfRangeException, MaxCountExceededException
- Parameters:
observed- array of observed frequency countsexpected- array of expected frequency countsalpha- significance level of the test- Returns:
- true iff null hypothesis can be rejected with confidence 1 - alpha
- Throws:
NotPositiveExceptionNotStrictlyPositiveExceptionDimensionMismatchExceptionOutOfRangeExceptionMaxCountExceededException- See Also:
ChiSquareTest.chiSquareTest(double[], long[], double)
-
chiSquareTest
public static double chiSquareTest(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException
- Parameters:
observed- array of observed frequency countsexpected- array of expected frequency counts- Returns:
- p-value
- Throws:
NotPositiveExceptionNotStrictlyPositiveExceptionDimensionMismatchExceptionMaxCountExceededException- See Also:
ChiSquareTest.chiSquareTest(double[], long[])
-
chiSquareTest
public static boolean chiSquareTest(long[][] counts, double alpha) throws NullArgumentException, DimensionMismatchException, NotPositiveException, OutOfRangeException, MaxCountExceededException
- Parameters:
counts- array representation of 2-way tablealpha- significance level of the test- Returns:
- true iff null hypothesis can be rejected with confidence 1 - alpha
- Throws:
NullArgumentExceptionDimensionMismatchExceptionNotPositiveExceptionOutOfRangeExceptionMaxCountExceededException- See Also:
ChiSquareTest.chiSquareTest(long[][], double)
-
chiSquareTest
public static double chiSquareTest(long[][] counts) throws NullArgumentException, DimensionMismatchException, NotPositiveException, MaxCountExceededException
- Parameters:
counts- array representation of 2-way table- Returns:
- p-value
- Throws:
NullArgumentExceptionDimensionMismatchExceptionNotPositiveExceptionMaxCountExceededException- See Also:
ChiSquareTest.chiSquareTest(long[][])
-
chiSquareDataSetsComparison
public static double chiSquareDataSetsComparison(long[] observed1, long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException
- Parameters:
observed1- array of observed frequency counts of the first data setobserved2- array of observed frequency counts of the second data set- Returns:
- chiSquare test statistic
- Throws:
DimensionMismatchExceptionNotPositiveExceptionZeroException- Since:
- 1.2
- See Also:
ChiSquareTest.chiSquareDataSetsComparison(long[], long[])
-
chiSquareTestDataSetsComparison
public static double chiSquareTestDataSetsComparison(long[] observed1, long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException, MaxCountExceededException
- Parameters:
observed1- array of observed frequency counts of the first data setobserved2- array of observed frequency counts of the second data set- Returns:
- p-value
- Throws:
DimensionMismatchExceptionNotPositiveExceptionZeroExceptionMaxCountExceededException- 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
- Parameters:
observed1- array of observed frequency counts of the first data setobserved2- array of observed frequency counts of the second data setalpha- significance level of the test- Returns:
- true iff null hypothesis can be rejected with confidence 1 - alpha
- Throws:
DimensionMismatchExceptionNotPositiveExceptionZeroExceptionOutOfRangeExceptionMaxCountExceededException- Since:
- 1.2
- See Also:
ChiSquareTest.chiSquareTestDataSetsComparison(long[], long[], double)
-
oneWayAnovaFValue
public static double oneWayAnovaFValue(Collection<double[]> categoryData) throws NullArgumentException, DimensionMismatchException
- Parameters:
categoryData-Collectionofdouble[]arrays each containing data for one category- Returns:
- Fvalue
- Throws:
NullArgumentExceptionDimensionMismatchException- Since:
- 1.2
- See Also:
OneWayAnova.anovaFValue(Collection)
-
oneWayAnovaPValue
public static double oneWayAnovaPValue(Collection<double[]> categoryData) throws NullArgumentException, DimensionMismatchException, ConvergenceException, MaxCountExceededException
- Parameters:
categoryData-Collectionofdouble[]arrays each containing data for one category- Returns:
- Pvalue
- Throws:
NullArgumentExceptionDimensionMismatchExceptionConvergenceExceptionMaxCountExceededException- Since:
- 1.2
- See Also:
OneWayAnova.anovaPValue(Collection)
-
oneWayAnovaTest
public static boolean oneWayAnovaTest(Collection<double[]> categoryData, double alpha) throws NullArgumentException, DimensionMismatchException, OutOfRangeException, ConvergenceException, MaxCountExceededException
- Parameters:
categoryData-Collectionofdouble[]arrays each containing data for one categoryalpha- significance level of the test- Returns:
- true if the null hypothesis can be rejected with confidence 1 - alpha
- Throws:
NullArgumentExceptionDimensionMismatchExceptionOutOfRangeExceptionConvergenceExceptionMaxCountExceededException- Since:
- 1.2
- See Also:
OneWayAnova.anovaTest(Collection,double)
-
g
public static double g(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException
- Parameters:
observed- array of observed frequency countsexpected- array of expected frequency counts- Returns:
- G-Test statistic
- Throws:
NotPositiveExceptionNotStrictlyPositiveExceptionDimensionMismatchException- Since:
- 3.1
- See Also:
GTest.g(double[], long[])
-
gTest
public static double gTest(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException
- Parameters:
observed- array of observed frequency countsexpected- array of expected frequency counts- Returns:
- p-value
- Throws:
NotPositiveExceptionNotStrictlyPositiveExceptionDimensionMismatchExceptionMaxCountExceededException- Since:
- 3.1
- See Also:
GTest.gTest( double[], long[] )
-
gTestIntrinsic
public static double gTestIntrinsic(double[] expected, long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException
- Parameters:
observed- array of observed frequency countsexpected- array of expected frequency counts- Returns:
- p-value
- Throws:
NotPositiveExceptionNotStrictlyPositiveExceptionDimensionMismatchExceptionMaxCountExceededException- 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
- Parameters:
observed- array of observed frequency countsexpected- array of expected frequency countsalpha- significance level of the test- Returns:
- true iff null hypothesis can be rejected with confidence 1 - alpha
- Throws:
NotPositiveExceptionNotStrictlyPositiveExceptionDimensionMismatchExceptionOutOfRangeExceptionMaxCountExceededException- Since:
- 3.1
- See Also:
GTest.gTest( double[],long[],double)
-
gDataSetsComparison
public static double gDataSetsComparison(long[] observed1, long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException
- Parameters:
observed1- array of observed frequency counts of the first data setobserved2- array of observed frequency counts of the second data set- Returns:
- G-Test statistic
- Throws:
DimensionMismatchExceptionNotPositiveExceptionZeroException- 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
- Parameters:
k11- number of times the two events occurred together (AB)k12- number of times the second event occurred WITHOUT the first event (notA,B)k21- number of times the first event occurred WITHOUT the second event (A, notB)k22- number of times something else occurred (i.e. was neither of these events (notA, notB)- Returns:
- root log-likelihood ratio
- Throws:
DimensionMismatchExceptionNotPositiveExceptionZeroException- 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
- Parameters:
observed1- array of observed frequency counts of the first data setobserved2- array of observed frequency counts of the second data set- Returns:
- p-value
- Throws:
DimensionMismatchExceptionNotPositiveExceptionZeroExceptionMaxCountExceededException- 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
- Parameters:
observed1- array of observed frequency counts of the first data setobserved2- array of observed frequency counts of the second data setalpha- significance level of the test- Returns:
- true iff null hypothesis can be rejected with confidence 1 - alpha
- Throws:
DimensionMismatchExceptionNotPositiveExceptionZeroExceptionOutOfRangeExceptionMaxCountExceededException- Since:
- 3.1
- See Also:
GTest.gTestDataSetsComparison(long[],long[],double)
-
kolmogorovSmirnovStatistic
public static double kolmogorovSmirnovStatistic(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data) throws InsufficientDataException, NullArgumentException
- Parameters:
dist- reference distributiondata- sample being evaluated- Returns:
- Kolmogorov-Smirnov statistic \(D_n\)
- Throws:
InsufficientDataExceptionNullArgumentException- Since:
- 3.3
- See Also:
KolmogorovSmirnovTest.kolmogorovSmirnovStatistic(ContinuousDistribution, double[])
-
kolmogorovSmirnovTest
public static double kolmogorovSmirnovTest(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data) throws InsufficientDataException, NullArgumentException
- Parameters:
dist- reference distributiondata- sample being being evaluated- Returns:
- the p-value associated with the null hypothesis that
datais a sample fromdistribution - Throws:
InsufficientDataExceptionNullArgumentException- Since:
- 3.3
- See Also:
KolmogorovSmirnovTest.kolmogorovSmirnovTest(ContinuousDistribution, double[])
-
kolmogorovSmirnovTest
public static double kolmogorovSmirnovTest(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data, boolean strict) throws InsufficientDataException, NullArgumentException
- Parameters:
dist- reference distributiondata- sample being being evaluatedstrict- whether or not to force exact computation of the p-value- Returns:
- the p-value associated with the null hypothesis that
datais a sample fromdistribution - Throws:
InsufficientDataExceptionNullArgumentException- Since:
- 3.3
- See Also:
KolmogorovSmirnovTest.kolmogorovSmirnovTest(ContinuousDistribution, double[], boolean)
-
kolmogorovSmirnovTest
public static boolean kolmogorovSmirnovTest(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data, double alpha) throws InsufficientDataException, NullArgumentException
- Parameters:
dist- reference distributiondata- sample being being evaluatedalpha- significance level of the test- Returns:
- true iff the null hypothesis that
datais a sample fromdistributioncan be rejected with confidence 1 -alpha - Throws:
InsufficientDataExceptionNullArgumentException- Since:
- 3.3
- See Also:
KolmogorovSmirnovTest.kolmogorovSmirnovTest(ContinuousDistribution, double[], double)
-
kolmogorovSmirnovStatistic
public static double kolmogorovSmirnovStatistic(double[] x, double[] y) throws InsufficientDataException, NullArgumentException
- Parameters:
x- first sampley- second sample- Returns:
- test statistic \(D_{n,m}\) used to evaluate the null hypothesis that
xandyrepresent samples from the same underlying distribution - Throws:
InsufficientDataExceptionNullArgumentException- Since:
- 3.3
- See Also:
KolmogorovSmirnovTest.kolmogorovSmirnovStatistic(double[], double[])
-
kolmogorovSmirnovTest
public static double kolmogorovSmirnovTest(double[] x, double[] y) throws InsufficientDataException, NullArgumentException
- Parameters:
x- first sample datasety- second sample dataset- Returns:
- p-value associated with the null hypothesis that
xandyrepresent samples from the same distribution - Throws:
InsufficientDataExceptionNullArgumentException- Since:
- 3.3
- See Also:
KolmogorovSmirnovTest.kolmogorovSmirnovTest(double[], double[])
-
kolmogorovSmirnovTest
public static double kolmogorovSmirnovTest(double[] x, double[] y, boolean strict) throws InsufficientDataException, NullArgumentException
- Parameters:
x- first sample dataset.y- second sample dataset.strict- whether or not the probability to compute is expressed as a strict inequality (ignored for large samples).- Returns:
- p-value associated with the null hypothesis that
xandyrepresent samples from the same distribution. - Throws:
InsufficientDataExceptionNullArgumentException- Since:
- 3.3
- See Also:
KolmogorovSmirnovTest.kolmogorovSmirnovTest(double[], double[], boolean)
-
exactP
public static double exactP(double d, int m, int n, boolean strict)
- Parameters:
d- D-statistic valuen- first sample sizem- second sample sizestrict- whether or not the probability to compute is expressed as a strict inequality- Returns:
- probability that a randomly selected m-n partition of m + n generates \(D_{n,m}\)
greater than (resp. greater than or equal to)
d - Since:
- 3.3
- See Also:
KolmogorovSmirnovTest.exactP(double, int, int, boolean)
-
approximateP
public static double approximateP(double d, int n, int m)
- Parameters:
d- D-statistic valuen- first sample sizem- second sample size- Returns:
- approximate probability that a randomly selected m-n partition of m + n generates
\(D_{n,m}\) greater than
d - 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, org.apache.commons.rng.UniformRandomProvider rng)
- Parameters:
d- D-statistic valuen- first sample sizem- second sample sizeiterations- number of random partitions to generatestrict- whether or not the probability to compute is expressed as a strict inequalityrng- RNG used for generating the partitions.- Returns:
- proportion of randomly generated m-n partitions of m + n that result in \(D_{n,m}\)
greater than (resp. greater than or equal to)
d - Since:
- 3.3
- See Also:
KolmogorovSmirnovTest.monteCarloP(double,int,int,boolean,int,UniformRandomProvider)
-
-