[
https://issues.apache.org/jira/browse/MATH-1401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16002447#comment-16002447
]
Bruno P. Kinoshita commented on MATH-1401:
------------------------------------------
To make it easier, will start naming the two cases we have. Case #1 is the one
I had some time to study today, and is when **number of successes is equals
zero**. And Case #2 is where **number of successes is equal to the number of
trials".
The exception is raised
[here|https://github.com/apache/commons-math/blob/20403f09bfe6f06626cd1253042b848e38f038fd/src/main/java/org/apache/commons/math4/stat/interval/ConfidenceInterval.java#L101]:
{code}
# class: ConfidenceInterval
/**
* Verifies that (lower, upper) is a valid non-empty interval and confidence
* is strictly between 0 and 1.
*
* @param lower lower endpoint
* @param upper upper endpoint
* @param confidence confidence level
*/
private void checkParameters(double lower, double upper, double confidence)
{
if (lower >= upper) { <---------------------- HERE, both are 0 <=> 0
throw new
MathIllegalArgumentException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
lower, upper);
}
if (confidence <= 0 || confidence >= 1) {
throw new
MathIllegalArgumentException(LocalizedFormats.OUT_OF_BOUNDS_CONFIDENCE_LEVEL,
confidence, 0, 1);
}
}
{code}
The code is checking if the confidence interval lower and upper bounds are
different. The [R
code|https://artax.karlin.mff.cuni.cz/r-help/library/PropCIs/html/exactci.html]
handles three cases, when the number of successes is zero, when the number of
successes and trials is the same, and the case where both previous constraints
are not true.
Our code in ClopperPearsonInterval checks if the number of successes is greater
than 0 only. Then returns a ConfidenceInterval object.
My current guess is that by understanding why the R code is treating these
three cases, we may be able to confirm if it makes sense adding some if/else
for these constraints in our Java code too.
> 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
> Fix For: 4.0
>
>
> 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
(v6.3.15#6346)