commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michele De Stefano (JIRA)" <>
Subject [jira] [Commented] (MATH-1401) Exception at IntervalUtils.getClopperPearsonInterval
Date Wed, 17 Apr 2019 21:52:00 GMT


Michele De Stefano commented on MATH-1401:

Dear Gilles,

I've just attached the modified unit test ( and the modified
(now working) code (

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

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,





> Exception at IntervalUtils.getClopperPearsonInterval
> ----------------------------------------------------
>                 Key: MATH-1401
>                 URL:
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.6.1
>            Reporter: Art
>            Assignee: Bruno P. Kinoshita
>            Priority: Major
>             Fix For: 4.0
>         Attachments:,
> 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

View raw message