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:11:34 UTC
[math] MATH-1257
Repository: commons-math
Updated Branches:
refs/heads/MATH_3_X aea9cfb34 -> 49a9e6e87
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/49a9e6e8
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/49a9e6e8
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/49a9e6e8
Branch: refs/heads/MATH_3_X
Commit: 49a9e6e8742cb6e05abf0219705338d95f732e12
Parents: aea9cfb
Author: Gilles <er...@apache.org>
Authored: Wed Aug 19 23:10:07 2015 +0200
Committer: Gilles <er...@apache.org>
Committed: Wed Aug 19 23:10:07 2015 +0200
----------------------------------------------------------------------
src/changes/changes.xml | 4 ++++
.../commons/math3/distribution/NormalDistribution.java | 2 +-
.../math3/distribution/NormalDistributionTest.java | 11 +++++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/49a9e6e8/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 124bfce..0e1fc5f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -51,6 +51,10 @@ If the output is not quite correct, check for invisible trailing spaces!
</properties>
<body>
<release version="3.6" 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">
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/49a9e6e8/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java b/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java
index 0fc839f..08cde66 100644
--- a/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java
+++ b/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java
@@ -191,7 +191,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/49a9e6e8/src/test/java/org/apache/commons/math3/distribution/NormalDistributionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/distribution/NormalDistributionTest.java b/src/test/java/org/apache/commons/math3/distribution/NormalDistributionTest.java
index 5a7597b..1cd9d0f 100644
--- a/src/test/java/org/apache/commons/math3/distribution/NormalDistributionTest.java
+++ b/src/test/java/org/apache/commons/math3/distribution/NormalDistributionTest.java
@@ -110,6 +110,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();