commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1292572 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/TriangularDistribution.java
Date Wed, 22 Feb 2012 23:04:33 GMT
Author: erans
Date: Wed Feb 22 23:04:32 2012
New Revision: 1292572

URL: http://svn.apache.org/viewvc?rev=1292572&view=rev
Log:
MATH-746
Removed strict equality special case.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/TriangularDistribution.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/TriangularDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/TriangularDistribution.java?rev=1292572&r1=1292571&r2=1292572&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/TriangularDistribution.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/TriangularDistribution.java
Wed Feb 22 23:04:32 2012
@@ -251,20 +251,16 @@ public class TriangularDistribution exte
     @Override
     public double inverseCumulativeProbability(double p)
         throws OutOfRangeException {
-        if (p < 0.0 || p > 1.0) {
+        if (p < 0 || p > 1) {
             throw new OutOfRangeException(p, 0, 1);
         }
-        if (p == 0.0) {
+        if (p == 0) {
             return a;
         }
-        if (p == 1.0) {
+        if (p == 1) {
             return b;
         }
-        final double pc = (c - a) / (b - a);
-        if (p == pc) {
-            return c;
-        }
-        if (p < pc) {
+        if (p <= (c - a) / (b - a)) {
             return a + FastMath.sqrt(p * (b - a) * (c - a));
         }
         return b - FastMath.sqrt((1 - p) * (b - a) * (b - c));



Mime
View raw message