[ https://issues.apache.org/jira/browse/MATH-1381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15999737#comment-15999737 ]
Bruno P. Kinoshita commented on MATH-1381: ------------------------------------------ Agree with [~erans] on spending some more time reviewing the current implementation. Today I spent some time reviewing distributions, binomial, and tests. Then looked at our BinomialTest, but still couldn't tell what was wrong. Then looked at other Java implementations, until stumbled across [hipparchus|https://github.com/Hipparchus-Math/hipparchus]. Their BinomialTest implementation has an extra if, to check when both extreme values are equals. https://github.com/Hipparchus-Math/hipparchus/blob/ff26617bd14472fa84d70e8efe66c1177f952145/hipparchus-stat/src/main/java/org/hipparchus/stat/inference/BinomialTest.java#L131 The comment next to it says {quote}One side can't move{quote} And from our Javadocs: {quote}The lower value is added to the p-Value (if both values are equal, both are added). Then we continue with the next extreme value, until we added the value for the actual observed sample.{quote} Nothing obvious for me, but with that check, we get precisely 1.0 as p-value for the example reported in this issue. Added the pull request here: https://github.com/apache/commons-math/pull/59 But probably worth combining with the tests from https://github.com/apache/commons-math/pull/43. Hope that helps Bruno > BinomialTest P-value > 1 > ------------------------ > > Key: MATH-1381 > URL: https://issues.apache.org/jira/browse/MATH-1381 > Project: Commons Math > Issue Type: Bug > Reporter: Wang Qiang > Fix For: 4.0 > > > When I use the Binomial Test, I got p-value > 1 for two sided check. > Example: > (new BinomialTest()).binomialTest(200, 200, 0.9950429, > AlternativeHypothesis.TWO_SIDED) == 1.3701357550780435 > In my case, if the expected p-value is 1 (calculated by package in other > language, scipy in this case), the p-value returned could be > 1 -- This message was sent by Atlassian JIRA (v6.3.15#6346)