diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/BinomialTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/BinomialTest.java index a7deb3187..9a601bb38 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/BinomialTest.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/BinomialTest.java @@ -122,7 +122,7 @@ public class BinomialTest { final BinomialDistribution distribution = BinomialDistribution.of(numberOfTrials, probability); switch (alternativeHypothesis) { case GREATER_THAN: - return 1 - distribution.cumulativeProbability(numberOfSuccesses - 1); + return distribution.survivalProbability(numberOfSuccesses - 1); case LESS_THAN: return distribution.cumulativeProbability(numberOfSuccesses); case TWO_SIDED: diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTest.java index eef09933f..3cf36875d 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTest.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTest.java @@ -157,7 +157,7 @@ public class ChiSquareTest { // pass a null rng to avoid unneeded overhead as we will not sample from this distribution final ChiSquaredDistribution distribution = ChiSquaredDistribution.of(expected.length - 1.0); - return 1.0 - distribution.cumulativeProbability(chiSquare(expected, observed)); + return distribution.survivalProbability(chiSquare(expected, observed)); } /** @@ -330,7 +330,7 @@ public class ChiSquareTest { double df = ((double) counts.length -1) * ((double) counts[0].length - 1); // pass a null rng to avoid unneeded overhead as we will not sample from this distribution final ChiSquaredDistribution distribution = ChiSquaredDistribution.of(df); - return 1 - distribution.cumulativeProbability(chiSquare(counts)); + return distribution.survivalProbability(chiSquare(counts)); } /** @@ -532,7 +532,7 @@ public class ChiSquareTest { // pass a null rng to avoid unneeded overhead as we will not sample from this distribution final ChiSquaredDistribution distribution = ChiSquaredDistribution.of((double) observed1.length - 1); - return 1 - distribution.cumulativeProbability( + return distribution.survivalProbability( chiSquareDataSetsComparison(observed1, observed2)); } diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/GTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/GTest.java index 42273e625..3b82b74a7 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/GTest.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/GTest.java @@ -155,7 +155,7 @@ public class GTest { // pass a null rng to avoid unneeded overhead as we will not sample from this distribution final ChiSquaredDistribution distribution = ChiSquaredDistribution.of(expected.length - 1.0); - return 1.0 - distribution.cumulativeProbability(g(expected, observed)); + return distribution.survivalProbability(g(expected, observed)); } /** @@ -186,7 +186,7 @@ public class GTest { // pass a null rng to avoid unneeded overhead as we will not sample from this distribution final ChiSquaredDistribution distribution = ChiSquaredDistribution.of(expected.length - 2.0); - return 1.0 - distribution.cumulativeProbability(g(expected, observed)); + return distribution.survivalProbability(g(expected, observed)); } /** @@ -476,7 +476,7 @@ public class GTest { // pass a null rng to avoid unneeded overhead as we will not sample from this distribution final ChiSquaredDistribution distribution = ChiSquaredDistribution.of((double) observed1.length - 1); - return 1 - distribution.cumulativeProbability( + return distribution.survivalProbability( gDataSetsComparison(observed1, observed2)); } diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/OneWayAnova.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/OneWayAnova.java index 2643270e0..8b93f1775 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/OneWayAnova.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/OneWayAnova.java @@ -104,9 +104,9 @@ public class OneWayAnova { * {@link org.apache.commons.statistics.distribution.FDistribution * commons-math F Distribution implementation} to estimate the exact * p-value, using the formula
- * p = 1 - cumulativeProbability(F)- * where
F
is the F value and cumulativeProbability
- * is the commons-math implementation of the F distribution.
+ * p = survivalProbability(F)
+ * where F
is the F value and survivalProbability = 1 - cumulativeProbability
+ * is the commons-statistics implementation of the F distribution.
*
* @param categoryData Collection
of double[]
* arrays each containing data for one category
@@ -126,7 +126,7 @@ public class OneWayAnova {
// No try-catch or advertised exception because args are valid
// pass a null rng to avoid unneeded overhead as we will not sample from this distribution
final FDistribution fdist = FDistribution.of(a.dfbg, a.dfwg);
- return 1.0 - fdist.cumulativeProbability(a.f);
+ return fdist.survivalProbability(a.f);
}
/**
@@ -142,9 +142,9 @@ public class OneWayAnova {
* {@link org.apache.commons.statistics.distribution.FDistribution
* commons-math F Distribution implementation} to estimate the exact
* p-value, using the formula- * p = 1 - cumulativeProbability(F)- * where
F
is the F value and cumulativeProbability
- * is the commons-math implementation of the F distribution.
+ * p = survivalProbability(F)
+ * where F
is the F value and survivalProbability = 1 - cumulativeProbability
+ * is the commons-statistics implementation of the F distribution.
*
* @param categoryData Collection
of {@link SummaryStatistics}
* each containing data for one category
@@ -167,7 +167,7 @@ public class OneWayAnova {
final AnovaStats a = anovaStats(categoryData, allowOneElementData);
// pass a null rng to avoid unneeded overhead as we will not sample from this distribution
final FDistribution fdist = FDistribution.of(a.dfbg, a.dfwg);
- return 1.0 - fdist.cumulativeProbability(a.f);
+ return fdist.survivalProbability(a.f);
}
/**
@@ -221,9 +221,9 @@ public class OneWayAnova {
* {@link org.apache.commons.statistics.distribution.FDistribution
* commons-math F Distribution implementation} to estimate the exact
* p-value, using the formula- * p = 1 - cumulativeProbability(F)- * where
F
is the F value and cumulativeProbability
- * is the commons-math implementation of the F distribution.
+ * p = survivalProbability(F)
+ * where F
is the F value and survivalProbability = 1 - cumulativeProbability
+ * is the commons-statistics implementation of the F distribution.
* True is returned iff the estimated p-value is less than alpha.
* * @param categoryDataCollection
of double[]
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/AgrestiCoullInterval.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/AgrestiCoullInterval.java
index 1002abb7e..95d4caea6 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/AgrestiCoullInterval.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/AgrestiCoullInterval.java
@@ -35,7 +35,7 @@ public class AgrestiCoullInterval implements BinomialConfidenceInterval {
IntervalUtils.checkParameters(numberOfTrials, numberOfSuccesses, confidenceLevel);
final double alpha = (1.0 - confidenceLevel) / 2;
final NormalDistribution normalDistribution = NormalDistribution.of(0, 1);
- final double z = normalDistribution.inverseCumulativeProbability(1 - alpha);
+ final double z = normalDistribution.inverseSurvivalProbability(alpha);
final double zSquared = JdkMath.pow(z, 2);
final double modifiedNumberOfTrials = numberOfTrials + zSquared;
final double modifiedSuccessesRatio = (1.0 / modifiedNumberOfTrials) * (numberOfSuccesses + 0.5 * zSquared);
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/ClopperPearsonInterval.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/ClopperPearsonInterval.java
index a28522cdc..b8b23034e 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/ClopperPearsonInterval.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/ClopperPearsonInterval.java
@@ -42,7 +42,7 @@ public class ClopperPearsonInterval implements BinomialConfidenceInterval {
if (numberOfSuccesses > 0) {
final FDistribution distributionLowerBound = FDistribution.of(2.0 * (numberOfTrials - numberOfSuccesses + 1),
2.0 * numberOfSuccesses);
- final double fValueLowerBound = distributionLowerBound.inverseCumulativeProbability(1 - alpha);
+ final double fValueLowerBound = distributionLowerBound.inverseSurvivalProbability(alpha);
lowerBound = numberOfSuccesses /
(numberOfSuccesses + (numberOfTrials - numberOfSuccesses + 1) * fValueLowerBound);
}
@@ -50,7 +50,7 @@ public class ClopperPearsonInterval implements BinomialConfidenceInterval {
if (numberOfSuccesses < numberOfTrials) {
final FDistribution distributionUpperBound = FDistribution.of(2.0 * (numberOfSuccesses + 1),
2.0 * (numberOfTrials - numberOfSuccesses));
- final double fValueUpperBound = distributionUpperBound.inverseCumulativeProbability(1 - alpha);
+ final double fValueUpperBound = distributionUpperBound.inverseSurvivalProbability(alpha);
upperBound = (numberOfSuccesses + 1) * fValueUpperBound /
(numberOfTrials - numberOfSuccesses + (numberOfSuccesses + 1) * fValueUpperBound);
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/NormalApproximationInterval.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/NormalApproximationInterval.java
index fb085432d..8871fcaa3 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/NormalApproximationInterval.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/NormalApproximationInterval.java
@@ -37,7 +37,7 @@ public class NormalApproximationInterval implements BinomialConfidenceInterval {
final double mean = (double) numberOfSuccesses / (double) numberOfTrials;
final double alpha = (1.0 - confidenceLevel) / 2;
final NormalDistribution normalDistribution = NormalDistribution.of(0, 1);
- final double difference = normalDistribution.inverseCumulativeProbability(1 - alpha) *
+ final double difference = normalDistribution.inverseSurvivalProbability(alpha) *
JdkMath.sqrt(1.0 / numberOfTrials * mean * (1 - mean));
return new ConfidenceInterval(mean - difference, mean + difference, confidenceLevel);
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/WilsonScoreInterval.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/WilsonScoreInterval.java
index e08d58714..c57c122df 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/WilsonScoreInterval.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/WilsonScoreInterval.java
@@ -33,7 +33,7 @@ public class WilsonScoreInterval implements BinomialConfidenceInterval {
IntervalUtils.checkParameters(numberOfTrials, numberOfSuccesses, confidenceLevel);
final double alpha = (1 - confidenceLevel) / 2;
final NormalDistribution normalDistribution = NormalDistribution.of(0, 1);
- final double z = normalDistribution.inverseCumulativeProbability(1 - alpha);
+ final double z = normalDistribution.inverseSurvivalProbability(alpha);
final double zSquared = z * z;
final double oneOverNumTrials = 1d / numberOfTrials;
final double zSquaredOverNumTrials = zSquared * oneOverNumTrials;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegression.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegression.java
index ada0c3b2a..44d73219c 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegression.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegression.java
@@ -695,7 +695,7 @@ public class SimpleRegression implements UpdatingMultipleLinearRegression {
// No advertised NotStrictlyPositiveException here - will return NaN above
TDistribution distribution = TDistribution.of(n - 2d);
return getSlopeStdErr() *
- distribution.inverseCumulativeProbability(1d - alpha / 2d);
+ distribution.inverseSurvivalProbability(alpha / 2d);
}
/**
@@ -726,7 +726,7 @@ public class SimpleRegression implements UpdatingMultipleLinearRegression {
}
// No advertised NotStrictlyPositiveException here - will return NaN above
TDistribution distribution = TDistribution.of(n - 2d);
- return 2d * (1.0 - distribution.cumulativeProbability(
+ return 2d * (distribution.survivalProbability(
JdkMath.abs(getSlope()) / getSlopeStdErr()));
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/correlation/PearsonsCorrelationTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/correlation/PearsonsCorrelationTest.java
index 87f5631f9..cb1d36a6b 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/correlation/PearsonsCorrelationTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/correlation/PearsonsCorrelationTest.java
@@ -237,7 +237,7 @@ public class PearsonsCorrelationTest {
for (int i = 0; i < 5; i++) {
for (int j = 0; j < i; j++) {
double t = JdkMath.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j);
- double p = 2 * (1 - tDistribution.cumulativeProbability(t));
+ double p = 2 * tDistribution.survivalProbability(t);
Assert.assertEquals(p, pValues.getEntry(i, j), 10E-15);
}
}