Calculator
Formula Used
The binomial probability for exactly k successes is:
P(X = k) = C(n, k) p0^k (1 - p0)^(n - k)
C(n, k) = n! / (k! (n - k)!)
For a lower tail test, the calculator adds probabilities from 0 to x. For an upper tail test, it adds probabilities from x to n. For a two sided exact test, it adds terms whose probability is no greater than the observed term.
The confidence interval uses the Clopper Pearson exact method, based on beta distribution quantiles.
How to Use This Calculator
- Enter the observed number of successes.
- Enter the total number of independent trials.
- Enter the null probability, such as 0.5.
- Select the alternative hypothesis used in your test.
- Set the confidence level and decision alpha.
- Press Calculate to view the result above the form.
- Use CSV or PDF download for report records.
Example Data Table
| Successes x | Trials n | p0 | Alternative | Use case |
|---|---|---|---|---|
| 8 | 12 | 0.50 | two.sided | Coin fairness check |
| 2 | 15 | 0.50 | less | Low success rate check |
| 22 | 30 | 0.60 | greater | Improvement claim check |
| 4 | 10 | 0.25 | greater | Defect rate review |
About This Binomial Test Tool
A binomial test checks whether an observed count of successes agrees with a claimed probability. It is useful when each trial has only two outcomes. Examples include pass or fail, defect or good, yes or no, and heads or tails. This calculator follows the exact method, not a large sample shortcut. It lets you reproduce the same logic used by R, while still seeing every manual step.
Why Exact Testing Matters
Exact testing is important when the sample is small, the success probability is extreme, or accuracy matters. A normal approximation can be quick, but it may miss tail behavior. The binomial distribution gives the direct probability for each possible success count. The p value is then built from those probabilities. This makes the method clear and defensible.
Manual and R Style Workflow
Enter the number of successes, total trials, hypothesized probability, alternative form, confidence level, and decision alpha. The calculator computes the observed sample proportion. It then evaluates the binomial probability mass formula for relevant counts. For a lower tailed test, it sums probabilities from zero through the observed count. For an upper tailed test, it sums from the observed count through the total trials. For a two sided test, it sums outcomes that are at least as unusual as the observed outcome.
Understanding the Output
The result area shows the p value, exact confidence interval, decision, observed probability, null probability, and a matching command style. The probability table shows which terms were included in the manual sum. This helps students compare a by hand solution with software output. It also helps analysts explain an exact test in reports.
Best Use Cases
Use this calculator for teaching, homework checking, quality control, A/B testing notes, survey response checks, and clinical screening examples. Always confirm that trials are independent and share the same probability under the null hypothesis. If trials are dependent, the binomial model may not fit. In that case, choose a method that matches the study design. Keep input units simple. Successes must be whole counts. The null probability must stay between zero and one. Use the export buttons to save the audit trail after checking the displayed assumptions carefully before sharing final work.
FAQs
What is a binomial test?
It is an exact test for a success count from independent trials. It compares the observed count with a hypothesized probability.
When should I use the two sided option?
Use it when differences in either direction matter. It checks whether the observed count is unusually low or unusually high.
What does p0 mean?
p0 is the probability claimed by the null hypothesis. For a fair coin test, p0 is usually 0.5.
Does this match R output?
It follows the exact binomial logic used by a common R command style. Small rounding differences may appear in displayed decimals.
What is the confidence interval?
It is an exact interval for the true success probability. This page uses the Clopper Pearson method.
Why is the two sided p value not doubled?
The exact two sided method sums outcomes at least as unusual as the observation. This can differ from doubling one tail.
Can I use decimal successes?
No. Successes and trials must be whole counts because the binomial model counts discrete outcomes.
What should I export?
Export after checking inputs. The CSV is useful for spreadsheets. The PDF is useful for a quick report summary.