You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2015/08/19 23:14:49 UTC

[1/2] [math] MATH-1257

Repository: commons-math
Updated Branches:
  refs/heads/master e7e8c3f71 -> a7ef0455c


MATH-1257

Increased accuracy.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/03178c8b
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/03178c8b
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/03178c8b

Branch: refs/heads/master
Commit: 03178c8b15f1b522b98ded0f83cfb0e79f5ec4d3
Parents: e7e8c3f
Author: Gilles <er...@apache.org>
Authored: Wed Aug 19 23:02:40 2015 +0200
Committer: Gilles <er...@apache.org>
Committed: Wed Aug 19 23:02:40 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                                  |  4 ++++
 .../commons/math4/distribution/NormalDistribution.java   |  2 +-
 .../math4/distribution/NormalDistributionTest.java       | 11 +++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/03178c8b/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 65d428e..09773c4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,10 @@ If the output is not quite correct, check for invisible trailing spaces!
     </release>
 
     <release version="4.0" date="XXXX-XX-XX" description="">
+      <action dev="erans" type="fix" issue="MATH-1257" due-to="Bill Murphy">
+        Better accuracy in computation of cumulative probability of "NormalDistribution"
+        (package "o.a.c.m.distribution").
+      </action>
       <action dev="erans" type="fix" issue="MATH-1256"> <!-- backported to 3.6 -->
         Boundary check to construct an "Interval" (package "o.a.c.m.geometry.euclidean.oned").
       </action>

http://git-wip-us.apache.org/repos/asf/commons-math/blob/03178c8b/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java b/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java
index 6313ef0..5216867 100644
--- a/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/NormalDistribution.java
@@ -193,7 +193,7 @@ public class NormalDistribution extends AbstractRealDistribution {
         if (FastMath.abs(dev) > 40 * standardDeviation) {
             return dev < 0 ? 0.0d : 1.0d;
         }
-        return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2)));
+        return 0.5 * Erf.erfc(-dev / (standardDeviation * SQRT2));
     }
 
     /** {@inheritDoc}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/03178c8b/src/test/java/org/apache/commons/math4/distribution/NormalDistributionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/distribution/NormalDistributionTest.java b/src/test/java/org/apache/commons/math4/distribution/NormalDistributionTest.java
index 3ced97c..4e00f56 100644
--- a/src/test/java/org/apache/commons/math4/distribution/NormalDistributionTest.java
+++ b/src/test/java/org/apache/commons/math4/distribution/NormalDistributionTest.java
@@ -111,6 +111,17 @@ public class NormalDistributionTest extends RealDistributionAbstractTest {
         verifyInverseCumulativeProbabilities();
     }
 
+    // MATH-1257
+    @Test
+    public void testCumulativeProbability() {
+        final RealDistribution dist = new NormalDistribution(0, 1);
+        double x = -10;
+        double expected = 7.61985e-24;
+        double v = dist.cumulativeProbability(x);
+        double tol = 1e-5;
+        Assert.assertEquals(1, v / expected, 1e-5);
+    }
+
     @Test
     public void testGetMean() {
         NormalDistribution distribution = (NormalDistribution) getDistribution();


[2/2] [math] Backport tracking.

Posted by er...@apache.org.
Backport tracking.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/a7ef0455
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/a7ef0455
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/a7ef0455

Branch: refs/heads/master
Commit: a7ef0455c311ed9ccc4455f64c81aacb8bfe90fc
Parents: 03178c8
Author: Gilles <er...@apache.org>
Authored: Wed Aug 19 23:14:17 2015 +0200
Committer: Gilles <er...@apache.org>
Committed: Wed Aug 19 23:14:17 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7ef0455/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 09773c4..e4dc108 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -53,7 +53,7 @@ If the output is not quite correct, check for invisible trailing spaces!
     <release version="TBD" date="TBD" description="TBD">
     </release>
 
-    <release version="4.0" date="XXXX-XX-XX" description="">
+    <release version="4.0" date="XXXX-XX-XX" description=""> <!-- backported to 3.6 -->
       <action dev="erans" type="fix" issue="MATH-1257" due-to="Bill Murphy">
         Better accuracy in computation of cumulative probability of "NormalDistribution"
         (package "o.a.c.m.distribution").