commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-1065) EnumeratedRealDistribution.inverseCumulativeProbability returns values not in the samples set
Date Sat, 08 Feb 2014 19:31:20 GMT

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

Thomas Neidhart commented on MATH-1065:
---------------------------------------

Hi Phil,

thanks for looking into this. I updated the code to this:

{noformat}
    public double inverseCumulativeProbability(final double p) throws OutOfRangeException
{

        if (p < 0.0 || p > 1.0) {
            throw new OutOfRangeException(p, 0, 1);
        }

        double probability = 0;
        double x = getSupportLowerBound();
        for (final Pair<Double, Double> sample : innerDistribution.getPmf()) {
            if (sample.getValue() == 0.0) {
                continue;
            }
            probability += sample.getValue();
            x = sample.getKey();

            if (probability >= p) {
                break;
            }
        }

        return x;
    }
{noformat}

Which returns the same results as the EnumeratedIntegerDistribution for the same input values
and also succeeds in running all the test cases from the attached unit test.

> EnumeratedRealDistribution.inverseCumulativeProbability returns values not in the samples
set
> ---------------------------------------------------------------------------------------------
>
>                 Key: MATH-1065
>                 URL: https://issues.apache.org/jira/browse/MATH-1065
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.2
>            Reporter: matteodg
>             Fix For: 3.3
>
>         Attachments: EnumeratedRealDistributionTest.java
>
>
> The method EnumeratedRealDistribution.inverseCumulativeProbability() sometimes returns
values that are not in the initial samples domain...
> I will attach a test to exploit this bug.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message