You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2013/03/15 12:38:24 UTC
svn commit: r1456906 - in /commons/proper/math/trunk/src: changes/changes.xml
main/java/org/apache/commons/math3/distribution/NormalDistribution.java
Author: luc
Date: Fri Mar 15 11:38:23 2013
New Revision: 1456906
URL: http://svn.apache.org/r1456906
Log:
Use erfinv in the normal distribution.
Modified:
commons/proper/math/trunk/src/changes/changes.xml
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java
Modified: commons/proper/math/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1456906&r1=1456905&r2=1456906&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Fri Mar 15 11:38:23 2013
@@ -55,6 +55,12 @@ This is a minor release: It combines bug
Changes to existing features were made in a backwards-compatible
way such as to allow drop-in replacement of the v3.1[.1] JAR file.
">
+ <action dev="luc" type="update" >
+ Normal distribution now uses a direct implementation of the
+ inverse error function to compute inverse cumulative probability
+ instead of relying on a numerical solver. This is much faster,
+ more accurate and does not need convergence threshold.
+ </action>
<action dev="luc" type="add" issue="MATH-948" >
Implementations for inverse error function and inverse complementary
error functions have been added.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java?rev=1456906&r1=1456905&r2=1456906&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/NormalDistribution.java Fri Mar 15 11:38:23 2013
@@ -19,6 +19,7 @@ package org.apache.commons.math3.distrib
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
+import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.special.Erf;
import org.apache.commons.math3.util.FastMath;
@@ -152,6 +153,15 @@ public class NormalDistribution extends
return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2)));
}
+ /** {@inheritDoc} */
+ @Override
+ public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
+ if (p < 0.0 || p > 1.0) {
+ throw new OutOfRangeException(p, 0, 1);
+ }
+ return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
+ }
+
/**
* {@inheritDoc}
*