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

Michele De Stefano commented on MATH-1401:
------------------------------------------

Dear Gilles,

I've just attached the modified unit test (ClopperPearsonIntervalTest.java) and 
the modified (now working) code (ClopperPearsonInterval.java).

Your fix was failing to address the case with number of successes = 0.

Because I am also a data scientist and I have a lot of experience in Python 
scientific programming, I generated 3 meaningful test cases with expected 
results obtained by the same algorithm implemented in a Python package that I 
use (the package name is statsmodels). I use that package since a while and I 
trust its results (for our specific case, I've also partially verified them 
theoretically).

So, in the unit test you will find comments from myself, explaining which was 
the Python instruction I used to produce the expected numbers (so that anyone 
that is also able to program in Python can reproduce them).

I suspect (but I have not verified this) that we have similar issues with the 
implementation of the other algorithms that produce confidence intervals for 
the binomial distribution.

In summary, the 3 cases we need to test for each of these methods are
 # number of successes = 0, number of trials = N
 # number of successes = k, number of trials = N, 0 < k < N
 # number of successes = number of trials = N

The code I've attached now passes all the three of them.

 

Best regards,

Michele

[^ClopperPearsonIntervalTest.java]

[^ClopperPearsonInterval.java]

 

> Exception at IntervalUtils.getClopperPearsonInterval
> ----------------------------------------------------
>
>                 Key: MATH-1401
>                 URL: https://issues.apache.org/jira/browse/MATH-1401
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.6.1
>            Reporter: Art
>            Assignee: Bruno P. Kinoshita
>            Priority: Major
>             Fix For: 4.0
>
>         Attachments: ClopperPearsonInterval.java, 
> ClopperPearsonIntervalTest.java
>
>
> IntervalUtils.getClopperPearsonInterval throws an exception when number of 
> successes equals to zero or number of successes = number of trials.
> IntervalUtils.getClopperPearsonInterval(1, 0, 0.95) or 
> IntervalUtils.getClopperPearsonInterval(1, 1, 0.95) throws 
> org.apache.commons.math3.exception.NotStrictlyPositiveException despite that 
> its input parameters are valid. 
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to