commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-1431) EmpiricalDistribution cumulativeProbability can return NaN when evaluated within an empty bin.
Date Sun, 15 Oct 2017 20:55:00 GMT

    [ https://issues.apache.org/jira/browse/MATH-1431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16205298#comment-16205298
] 

Phil Steitz commented on MATH-1431:
-----------------------------------

The diagnosis above is correct.  The error is in EmpiricalDistribution#getKernel, which checks
for singleton or no-variance bins, but not empty bins.  The fix is to change the test in getKernel
to also return constant distribution for empty bins.  This is fixed in Hipparchus here: https://github.com/Hipparchus-Math/hipparchus/commit/96fdfa07b56f51cd4c398f6e659a064f43a4178f


> EmpiricalDistribution cumulativeProbability can return NaN when evaluated within an empty
bin.
> ----------------------------------------------------------------------------------------------
>
>                 Key: MATH-1431
>                 URL: https://issues.apache.org/jira/browse/MATH-1431
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.6.1
>            Reporter: Jay
>
> The NaN can be reproduced by the following program. Evaluating at x = 0.3, it appeared
that getkernel returned a NormalDistribution with mean of NaN and standardDeviation of NaN.
> {code:java}
>     final int len = 240000;
>     double[] data = new double[len];
>     for (int i = 0; i < len / 2; ++i) {
>         data[i] = 0;
>     }
>     for (int i = len / 2 + 1; i < len ; ++i) {
>         data[i] = 1;
>     }
>     int binCnt = Math.max(1, data.length / 10);
>     EmpiricalDistribution edist = new EmpiricalDistribution(binCnt);
>     edist.load(data);
>     double x = 0.3;
>     double y = edist.cumulativeProbability(x);
>     System.out.println("y is " + y);
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message