Use erfinv in the normal distribution.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1456906 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
747476596e
commit
97a3ed9e21
|
@ -55,6 +55,12 @@ This is a minor release: It combines bug fixes and new features.
|
||||||
Changes to existing features were made in a backwards-compatible
|
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.
|
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" >
|
<action dev="luc" type="add" issue="MATH-948" >
|
||||||
Implementations for inverse error function and inverse complementary
|
Implementations for inverse error function and inverse complementary
|
||||||
error functions have been added.
|
error functions have been added.
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.commons.math3.distribution;
|
||||||
|
|
||||||
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
|
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
|
||||||
import org.apache.commons.math3.exception.NumberIsTooLargeException;
|
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.exception.util.LocalizedFormats;
|
||||||
import org.apache.commons.math3.special.Erf;
|
import org.apache.commons.math3.special.Erf;
|
||||||
import org.apache.commons.math3.util.FastMath;
|
import org.apache.commons.math3.util.FastMath;
|
||||||
|
@ -152,6 +153,15 @@ public class NormalDistribution extends AbstractRealDistribution {
|
||||||
return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2)));
|
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}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue