Package ai.libs.jaicore.basic
Class StatisticsUtil
- java.lang.Object
-
- ai.libs.jaicore.basic.StatisticsUtil
-
public class StatisticsUtil extends java.lang.Object
Utils for computing some statistics from collections of doubles or arrays.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
mannWhitneyOneSidedSignificance(double[] sampleA, double[] sampleB)
Uses the MannWhitneyU test to carry out a single-sided significance test.static boolean
mannWhitneyTwoSidedSignificance(double[] sampleA, double[] sampleB)
Uses the MannWhitneyU test to determine whether the distributions of the the two given samples is significantly different (two-sided test).static boolean
mannWhitneyTwoSidedSignificance(java.util.Collection<java.lang.Double> sampleA, java.util.Collection<java.lang.Double> sampleB)
Uses the MannWhitneyU test to determine whether the distributions of the the two given samples is significantly different (two-sided test).static double
mannWhitneyTwoSidedSignificanceP(double[] sampleA, double[] sampleB)
Computes the p-value according to the MannWhitneyU test for iid. samples A and B.static double
max(java.util.Collection<? extends java.lang.Number> values)
Filters the maximum value of the given collection.static double
mean(java.util.Collection<? extends java.lang.Number> values)
Computes the mean of the given collection.static double
min(java.util.Collection<? extends java.lang.Number> values)
Filters the minimum value of the given collection.static double
standardDeviation(java.util.Collection<? extends java.lang.Number> values)
Computes the standard deviation of the given collection.static double
sum(java.util.Collection<? extends java.lang.Number> values)
Computes the sum of the given collection.static boolean
twoSampleTTestSignificance(double[] valuesA, double[] valuesB)
Carries out a two sample ttest to determine whether the distributions of the two given samples are significantly different.static boolean
twoSampleTTestSignificance(double mean1, double variance1, double n1, double mean2, double variance2, double n2)
Carries out a two sample ttest when the sampled values have already been aggregated to mean, variance, and n, to determine whether the distributions of the two given samples are significantly different.static boolean
twoSampleTTestSignificance(java.util.Collection<java.lang.Double> valuesA, java.util.Collection<java.lang.Double> valuesB)
Carries out a two sample ttest to determine whether the distributions of the two given samples are significantly different.static double
variance(java.util.Collection<? extends java.lang.Number> values)
Computes the variance of the given collection.static double
wilcoxonSignedRankSumTestP(double[] sampleA, double[] sampleB)
Computes the p-value according to the Wilcoxon signed rank test for related samples A and B.static boolean
wilcoxonSignedRankSumTestSingleSided(double[] sampleA, double[] sampleB)
Uses the Wilcoxon Signed Rank test to carry out a single-sided significance test.static boolean
wilcoxonSignedRankSumTestTwoSided(double[] sampleA, double[] sampleB)
Uses the Wilcoxon Signed Rank test to determine whether the difference of the distributions of the the two given samples is significantly different (two-sided test).
-
-
-
Method Detail
-
max
public static double max(java.util.Collection<? extends java.lang.Number> values)
Filters the maximum value of the given collection.- Parameters:
values
- Values to take the maximum from.- Returns:
- The maximum value of the provided collection.
-
min
public static double min(java.util.Collection<? extends java.lang.Number> values)
Filters the minimum value of the given collection.- Parameters:
values
- Values to take the minimum from.- Returns:
- The minimum value of the provided collection.
-
mean
public static double mean(java.util.Collection<? extends java.lang.Number> values)
Computes the mean of the given collection.- Parameters:
values
- Values to take the mean of.- Returns:
- The mean of the provided values.
-
sum
public static double sum(java.util.Collection<? extends java.lang.Number> values)
Computes the sum of the given collection.- Parameters:
values
- Values to take the sum of.- Returns:
- The sum of the provided values.
-
variance
public static double variance(java.util.Collection<? extends java.lang.Number> values)
Computes the variance of the given collection.- Parameters:
values
- Values to compute the variance for.- Returns:
- The variance of the provided values.
-
standardDeviation
public static double standardDeviation(java.util.Collection<? extends java.lang.Number> values)
Computes the standard deviation of the given collection.- Parameters:
values
- Values to compute the standard deviation for.- Returns:
- The standard deviation of the provided values.
-
wilcoxonSignedRankSumTestP
public static double wilcoxonSignedRankSumTestP(double[] sampleA, double[] sampleB)
Computes the p-value according to the Wilcoxon signed rank test for related samples A and B.- Parameters:
sampleA
- The first sample.sampleB
- The second sample.- Returns:
- The p-value of the test for the given two samples.
-
wilcoxonSignedRankSumTestTwoSided
public static boolean wilcoxonSignedRankSumTestTwoSided(double[] sampleA, double[] sampleB)
Uses the Wilcoxon Signed Rank test to determine whether the difference of the distributions of the the two given samples is significantly different (two-sided test).- Parameters:
sampleA
- The first sample.sampleB
- The second sample.- Returns:
- True iff the difference is significant (p-value < 0.05)
-
wilcoxonSignedRankSumTestSingleSided
public static boolean wilcoxonSignedRankSumTestSingleSided(double[] sampleA, double[] sampleB)
Uses the Wilcoxon Signed Rank test to carry out a single-sided significance test.- Parameters:
sampleA
- The first sample.sampleB
- The second sample.- Returns:
- True iff the difference is significant (p-value < 0.01)
-
mannWhitneyTwoSidedSignificanceP
public static double mannWhitneyTwoSidedSignificanceP(double[] sampleA, double[] sampleB)
Computes the p-value according to the MannWhitneyU test for iid. samples A and B.- Parameters:
sampleA
- The first sample.sampleB
- The second sample.- Returns:
- The p-value of the test for the given two samples.
-
mannWhitneyTwoSidedSignificance
public static boolean mannWhitneyTwoSidedSignificance(double[] sampleA, double[] sampleB)
Uses the MannWhitneyU test to determine whether the distributions of the the two given samples is significantly different (two-sided test).- Parameters:
sampleA
- The first sample.sampleB
- The second sample.- Returns:
- True iff the difference is significant (p-value < 0.05)
-
mannWhitneyTwoSidedSignificance
public static boolean mannWhitneyTwoSidedSignificance(java.util.Collection<java.lang.Double> sampleA, java.util.Collection<java.lang.Double> sampleB)
Uses the MannWhitneyU test to determine whether the distributions of the the two given samples is significantly different (two-sided test).- Parameters:
sampleA
- The first sample.sampleB
- The second sample.- Returns:
- True iff the difference is significant (p-value < 0.05)
-
mannWhitneyOneSidedSignificance
public static boolean mannWhitneyOneSidedSignificance(double[] sampleA, double[] sampleB)
Uses the MannWhitneyU test to carry out a single-sided significance test.- Parameters:
sampleA
- The first sample.sampleB
- The second sample.- Returns:
- True iff the difference is significant (p-value < 0.01)
-
twoSampleTTestSignificance
public static boolean twoSampleTTestSignificance(java.util.Collection<java.lang.Double> valuesA, java.util.Collection<java.lang.Double> valuesB)
Carries out a two sample ttest to determine whether the distributions of the two given samples are significantly different. Requires the distributions to be a normal distribution respectively.- Parameters:
valuesA
- The first sample..valuesB
- The second sample.- Returns:
- True iff the difference is significant (p-value < 0.05)
-
twoSampleTTestSignificance
public static boolean twoSampleTTestSignificance(double[] valuesA, double[] valuesB)
Carries out a two sample ttest to determine whether the distributions of the two given samples are significantly different. Requires the distributions to be a normal distribution respectively.- Parameters:
valuesA
- The first sample..valuesB
- The second sample.- Returns:
- True iff the difference is significant (p-value < 0.05)
-
twoSampleTTestSignificance
public static boolean twoSampleTTestSignificance(double mean1, double variance1, double n1, double mean2, double variance2, double n2)
Carries out a two sample ttest when the sampled values have already been aggregated to mean, variance, and n, to determine whether the distributions of the two given samples are significantly different. Requires the distributions to be a normal distribution respectively.- Parameters:
mean1
- The mean of the first sample.variance1
- The variance of the first sample.n1
- The sample size of the first sample.mean2
- The mean of the second sample.variance2
- The variance of the second sample.n2
- The sample size of the second sample.- Returns:
- True iff the difference is significant (p-value < 0.05)
-
-