MATH-1257

Increased accuracy.
This commit is contained in:
Gilles 2015-08-19 23:02:40 +02:00
parent e7e8c3f717
commit 03178c8b15
3 changed files with 16 additions and 1 deletions

View File

@ -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>

View File

@ -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}

View File

@ -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();