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 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(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data)
static double
kolmogorovSmirnovTest(double[] x, double[] y)
static double
kolmogorovSmirnovTest(double[] x, double[] y, boolean strict)
static double
kolmogorovSmirnovTest(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data)
static double
kolmogorovSmirnovTest(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data, boolean strict)
static boolean
kolmogorovSmirnovTest(org.apache.commons.statistics.distribution.ContinuousDistribution dist, double[] data, double alpha)
static double
monteCarloP(double d, int n, int m, boolean strict, int iterations, org.apache.commons.rng.UniformRandomProvider rng)
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)
-
-
-
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:
NullArgumentException
NumberIsTooSmallException
- 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:
NullArgumentException
NumberIsTooSmallException
- 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:
NullArgumentException
NumberIsTooSmallException
OutOfRangeException
MaxCountExceededException
- 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:
NullArgumentException
NumberIsTooSmallException
MaxCountExceededException
- 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:
NullArgumentException
NumberIsTooSmallException
MaxCountExceededException
- 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:
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
- 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:
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
- Parameters:
sample1
- array of sample data valuessample2
- array of sample data values- Returns:
- p-value for t-test
- Throws:
NullArgumentException
NoDataException
DimensionMismatchException
NumberIsTooSmallException
MaxCountExceededException
- 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:
NullArgumentException
NumberIsTooSmallException
- 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:
NullArgumentException
NumberIsTooSmallException
- 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:
NullArgumentException
NumberIsTooSmallException
- 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:
NullArgumentException
NumberIsTooSmallException
- 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:
NullArgumentException
NumberIsTooSmallException
OutOfRangeException
MaxCountExceededException
- 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:
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
- Parameters:
mu
- constant value to compare sample mean againstsampleStats
- StatisticalSummary describing sample data valuesalpha
- significance level of the test- Returns:
- p-value
- Throws:
NullArgumentException
NumberIsTooSmallException
OutOfRangeException
MaxCountExceededException
- 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:
NullArgumentException
NumberIsTooSmallException
MaxCountExceededException
- 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:
NullArgumentException
NumberIsTooSmallException
OutOfRangeException
MaxCountExceededException
- 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:
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
- 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:
NullArgumentException
NumberIsTooSmallException
OutOfRangeException
MaxCountExceededException
- 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:
NullArgumentException
NumberIsTooSmallException
MaxCountExceededException
- 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:
NotPositiveException
NotStrictlyPositiveException
DimensionMismatchException
- 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:
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
- 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:
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
- Parameters:
observed
- array of observed frequency countsexpected
- array of expected frequency counts- Returns:
- p-value
- 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
- 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:
NullArgumentException
DimensionMismatchException
NotPositiveException
OutOfRangeException
MaxCountExceededException
- 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:
NullArgumentException
DimensionMismatchException
NotPositiveException
MaxCountExceededException
- 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:
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
- 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:
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
- 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:
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
- Parameters:
categoryData
-Collection
ofdouble[]
arrays each containing data for one category- Returns:
- Fvalue
- Throws:
NullArgumentException
DimensionMismatchException
- Since:
- 1.2
- See Also:
OneWayAnova.anovaFValue(Collection)
-
oneWayAnovaPValue
public static double oneWayAnovaPValue(Collection<double[]> categoryData) throws NullArgumentException, DimensionMismatchException, ConvergenceException, MaxCountExceededException
- Parameters:
categoryData
-Collection
ofdouble[]
arrays each containing data for one category- Returns:
- Pvalue
- 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
- Parameters:
categoryData
-Collection
ofdouble[]
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:
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
- Parameters:
observed
- array of observed frequency countsexpected
- array of expected frequency counts- Returns:
- G-Test statistic
- 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
- Parameters:
observed
- array of observed frequency countsexpected
- array of expected frequency counts- Returns:
- p-value
- 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
- Parameters:
observed
- array of observed frequency countsexpected
- array of expected frequency counts- Returns:
- p-value
- 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
- 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:
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
- 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:
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
- 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:
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
- 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:
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
- 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:
DimensionMismatchException
NotPositiveException
ZeroException
OutOfRangeException
MaxCountExceededException
- 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:
InsufficientDataException
NullArgumentException
- 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
data
is a sample fromdistribution
- Throws:
InsufficientDataException
NullArgumentException
- 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
data
is a sample fromdistribution
- Throws:
InsufficientDataException
NullArgumentException
- 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
data
is a sample fromdistribution
can be rejected with confidence 1 -alpha
- Throws:
InsufficientDataException
NullArgumentException
- 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
x
andy
represent samples from the same underlying distribution - Throws:
InsufficientDataException
NullArgumentException
- 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
x
andy
represent samples from the same distribution - 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
- 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
x
andy
represent samples from the same distribution. - 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)
- 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)
-
-