From e994c42a8e20991920a3411472a6be3c3dde5a3d Mon Sep 17 00:00:00 2001 From: Sebastien Brisard Date: Tue, 6 Dec 2011 02:57:46 +0000 Subject: [PATCH] In distribution.AbstractRealDistribution.inverseCumulativeProbability(double), boundary cases (p == 0 and p == 1) are now handled correctly: concrete instances no longer need to override this method, which is removed (MATH-699). git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1210756 13f79535-47bb-0310-9956-ffa450edef68 --- .../math/distribution/BetaDistribution.java | 12 ------------ .../distribution/ChiSquaredDistribution.java | 17 ----------------- .../math/distribution/FDistribution.java | 18 ------------------ .../math/distribution/GammaDistribution.java | 17 ----------------- .../math/distribution/NormalDistribution.java | 17 ----------------- .../math/distribution/TDistribution.java | 17 ----------------- 6 files changed, 98 deletions(-) diff --git a/src/main/java/org/apache/commons/math/distribution/BetaDistribution.java b/src/main/java/org/apache/commons/math/distribution/BetaDistribution.java index a985eb255..e43eac6fe 100644 --- a/src/main/java/org/apache/commons/math/distribution/BetaDistribution.java +++ b/src/main/java/org/apache/commons/math/distribution/BetaDistribution.java @@ -133,18 +133,6 @@ public class BetaDistribution extends AbstractRealDistribution { } } - /** {@inheritDoc} */ - @Override - public double inverseCumulativeProbability(double p) { - if (p == 0) { - return 0; - } else if (p == 1) { - return 1; - } else { - return super.inverseCumulativeProbability(p); - } - } - /** {@inheritDoc} */ public double cumulativeProbability(double x) { if (x <= 0) { diff --git a/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java b/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java index 0987f937f..771b44493 100644 --- a/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java +++ b/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java @@ -91,23 +91,6 @@ public class ChiSquaredDistribution extends AbstractRealDistribution { return gamma.cumulativeProbability(x); } - /** - * {@inheritDoc} - * - * Returns {@code 0} when {@code p == 0} and - * {@code Double.POSITIVE_INFINITY} when {@code p == 1}. - */ - @Override - public double inverseCumulativeProbability(final double p) { - if (p == 0) { - return 0d; - } - if (p == 1) { - return Double.POSITIVE_INFINITY; - } - return super.inverseCumulativeProbability(p); - } - /** {@inheritDoc} */ @Override protected double getSolverAbsoluteAccuracy() { diff --git a/src/main/java/org/apache/commons/math/distribution/FDistribution.java b/src/main/java/org/apache/commons/math/distribution/FDistribution.java index 8c088fa77..6680aab58 100644 --- a/src/main/java/org/apache/commons/math/distribution/FDistribution.java +++ b/src/main/java/org/apache/commons/math/distribution/FDistribution.java @@ -18,7 +18,6 @@ package org.apache.commons.math.distribution; import org.apache.commons.math.exception.NotStrictlyPositiveException; -import org.apache.commons.math.exception.OutOfRangeException; import org.apache.commons.math.exception.util.LocalizedFormats; import org.apache.commons.math.special.Beta; import org.apache.commons.math.util.FastMath; @@ -155,23 +154,6 @@ public class FDistribution extends AbstractRealDistribution { return ret; } - /** - * {@inheritDoc} - * - * Returns {@code 0} when {@code p == 0} and - * {@code Double.POSITIVE_INFINITY} when {@code p == 1}. - */ - @Override - public double inverseCumulativeProbability(final double p) throws OutOfRangeException { - if (p == 0) { - return 0; - } - if (p == 1) { - return Double.POSITIVE_INFINITY; - } - return super.inverseCumulativeProbability(p); - } - /** * Access the numerator degrees of freedom. * diff --git a/src/main/java/org/apache/commons/math/distribution/GammaDistribution.java b/src/main/java/org/apache/commons/math/distribution/GammaDistribution.java index 8e5ccff4d..12a6029d4 100644 --- a/src/main/java/org/apache/commons/math/distribution/GammaDistribution.java +++ b/src/main/java/org/apache/commons/math/distribution/GammaDistribution.java @@ -144,23 +144,6 @@ public class GammaDistribution extends AbstractRealDistribution { return ret; } - /** - * {@inheritDoc} - * - * Returns {@code 0} when {@code p == 0} and - * {@code Double.POSITIVE_INFINITY} when {@code p == 1}. - */ - @Override - public double inverseCumulativeProbability(final double p) { - if (p == 0) { - return 0; - } - if (p == 1) { - return Double.POSITIVE_INFINITY; - } - return super.inverseCumulativeProbability(p); - } - /** {@inheritDoc} */ @Override protected double getSolverAbsoluteAccuracy() { diff --git a/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java b/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java index 082b815b4..d092aa322 100644 --- a/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java +++ b/src/main/java/org/apache/commons/math/distribution/NormalDistribution.java @@ -155,23 +155,6 @@ public class NormalDistribution extends AbstractRealDistribution { return 0.5 * Erf.erf(v0, v1); } - /** - * {@inheritDoc} - * - * Returns {@code Double.NEGATIVE_INFINITY} when {@code p == 0} - * and {@code Double.POSITIVE_INFINITY} for {@code p == 1}. - */ - @Override - public double inverseCumulativeProbability(final double p) { - if (p == 0) { - return Double.NEGATIVE_INFINITY; - } - if (p == 1) { - return Double.POSITIVE_INFINITY; - } - return super.inverseCumulativeProbability(p); - } - /** {@inheritDoc} */ @Override protected double getSolverAbsoluteAccuracy() { diff --git a/src/main/java/org/apache/commons/math/distribution/TDistribution.java b/src/main/java/org/apache/commons/math/distribution/TDistribution.java index d5698de1d..77829ab03 100644 --- a/src/main/java/org/apache/commons/math/distribution/TDistribution.java +++ b/src/main/java/org/apache/commons/math/distribution/TDistribution.java @@ -126,23 +126,6 @@ public class TDistribution extends AbstractRealDistribution { return ret; } - /** - * {@inheritDoc} - * - * Returns {@code Double.NEGATIVE_INFINITY} when {@code p = 0} - * and {@code Double.POSITIVE_INFINITY} when {@code p = 1}. - */ - @Override - public double inverseCumulativeProbability(final double p) { - if (p == 0) { - return Double.NEGATIVE_INFINITY; - } - if (p == 1) { - return Double.POSITIVE_INFINITY; - } - return super.inverseCumulativeProbability(p); - } - /** {@inheritDoc} */ @Override protected double getSolverAbsoluteAccuracy() {