You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Phil Steitz (JIRA)" <ji...@apache.org> on 2017/10/15 20:55:00 UTC

[jira] [Commented] (MATH-1431) EmpiricalDistribution cumulativeProbability can return NaN when evaluated within an empty bin.

    [ 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)