Details

Bug

Status: Resolved

Minor

Resolution: Fixed

3.6.1

None

None
Description
The code below produces the output "Pvalue for 10 trials, 5 successes, probability 0.5, twosided alternative is 1.2460937500000002", but pvalues should never be greater than 1. I think what is happening is that the test is adding both onesided alternatives, but both include the 5 successes probability, so it is counted twice. This happens whenever the number of successes is exactly what is expected based on number of trials and success probability (numberOfSuccesses = numberOfTrials * probability).
import org.apache.commons.math3.stat.inference.*; public class Main { public static void main(String args[]) { BinomialTest bt = new BinomialTest(); Double pval = bt.binomialTest(10, 5, 0.5, AlternativeHypothesis.TWO_SIDED); System.out.println("Pvalue for 10 trials, 5 successes, probability 0.5, twosided alternative is " + pval); } }