diff --git a/src/main/java/org/apache/commons/math3/stat/inference/BinomialTest.java b/src/main/java/org/apache/commons/math3/stat/inference/BinomialTest.java index 7b50bde7d..e201799d5 100644 --- a/src/main/java/org/apache/commons/math3/stat/inference/BinomialTest.java +++ b/src/main/java/org/apache/commons/math3/stat/inference/BinomialTest.java @@ -51,8 +51,8 @@ public class BinomialTest { * @param numberOfSuccesses number of successes observed * @param probability assumed probability of a single trial under the null hypothesis * @param alternativeHypothesis type of hypothesis being evaluated (one- or two-sided) - * @param confidenceLevel confidence level of the test - * @return true if the null hypothesis can be rejected with confidence {@code confidenceLevel} + * @param alpha significance level of the test + * @return true if the null hypothesis can be rejected with confidence {@code 1 - alpha} * @throws NotPositiveException if {@code numberOfTrials} or {@code numberOfSuccesses} is negative * @throws OutOfRangeException if {@code probability} is not between 0 and 1 * @throws MathIllegalArgumentException if {@code numberOfTrials} < {@code numberOfSuccesses} or @@ -60,9 +60,9 @@ public class BinomialTest { * @see AlternativeHypothesis */ public boolean binomialTest(int numberOfTrials, int numberOfSuccesses, double probability, - AlternativeHypothesis alternativeHypothesis, double confidenceLevel) { + AlternativeHypothesis alternativeHypothesis, double alpha) { double pValue = binomialTest(numberOfTrials, numberOfSuccesses, probability, alternativeHypothesis); - return pValue < 1 - confidenceLevel; + return pValue < alpha; } /** @@ -71,7 +71,15 @@ public class BinomialTest { * associated with a Binomial test. *
* The number returned is the smallest significance level at which one can reject the null hypothesis. - * The form of the hypothesis depends on {@code alternativeHypothesis}. + * The form of the hypothesis depends on {@code alternativeHypothesis}.
+ *+ * The p-Value represents the likelihood of getting a result at least as extreme as the sample, + * given the provided {@code probability} of success on a single trial. For single-sided tests, + * this value can be directly derived from the Binomial distribution. For the two-sided test, + * the implementation works as follows: we start by looking at the most extreme cases + * (0 success and n success where n is the number of trials from the sample) and determine their likelihood. + * 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.
** Preconditions: *