Connect via MCP →

Enter Calculation

Formula

Show calculation steps (4)
  1. Two-Sided p-value

    Two-Sided p-value: Exact Binomial Test Calculator

    Sum of all outcome probabilities no larger than the observed probability at x = k.

  2. One-Sided (Lower) p-value

    One-Sided (Lower) p-value: Exact Binomial Test Calculator

    Probability of observing k or fewer successes.

  3. One-Sided (Upper) p-value

    One-Sided (Upper) p-value: Exact Binomial Test Calculator

    Probability of observing k or more successes.

  4. Expected Successes

    Expected Successes: Exact Binomial Test Calculator

    Mean number of successes under the hypothesized probability.

Advertisement

Results

Two-sided p-value
0.109375
exact binomial test
Probability of observed count 0.043945
Expected successes (n × p) 5
One-sided lower P(X ≤ k) 0.989258
One-sided upper P(X ≥ k) 0.054688

What is the exact binomial test?

The exact binomial test evaluates whether the number of successes observed in a fixed number of independent yes/no trials is consistent with a hypothesized success probability. Unlike the normal approximation, it computes the p-value directly from the binomial distribution, so it is accurate even for small samples. This tool is universal — it applies to any binary experiment such as coin flips, conversion rates, defect counts, or pass/fail data.

How to use this calculator

Enter the number of successes k, the total number of trials n, and the hypothesized success probability p (between 0 and 1). The calculator returns the two-sided p-value, the probability of the observed count, the expected number of successes, and both one-sided p-values.

The formula explained

Each outcome \(x\) has probability $$P(X = x) = \binom{\text{n}}{x}\, \text{p}^{\,x}\,\bigl(1-\text{p}\bigr)^{\text{n}-x}.$$ The two-sided p-value sums the probabilities of every outcome that is as unlikely as, or less likely than, the one actually observed (\(P(x) \le P(k)\)): $$p\text{-value} = \sum_{x\,:\,P(X=x)\,\le\,P\left(X=\text{k}\right)} P(X = x).$$ The one-sided lower p-value is $$P\!\left(X \le \text{k}\right) = \sum_{x=0}^{\text{k}} \binom{\text{n}}{x}\, \text{p}^{\,x}\,\bigl(1-\text{p}\bigr)^{\text{n}-x}$$ and the upper is $$P\!\left(X \ge \text{k}\right) = \sum_{x=\text{k}}^{\text{n}} \binom{\text{n}}{x}\, \text{p}^{\,x}\,\bigl(1-\text{p}\bigr)^{\text{n}-x}.$$

Advertisement
Binomial distribution bar chart with tail bars shaded to show the two-sided p-value region
The two-sided p-value sums the probabilities of all outcomes at least as unlikely as the observed count k.

Worked example

Suppose you flip a coin 10 times and get 8 heads, testing whether the coin is fair (\(p = 0.5\)). The probability of exactly 8 heads is $$\binom{10}{8}\cdot 0.5^{10} = \frac{45}{1024} \approx 0.043945.$$ By symmetry, the equally-or-less-likely outcomes are 0,1,2,8,9,10 heads. Their total probability is $$\frac{2\cdot(1+10+45)}{1024} = \frac{112}{1024} \approx 0.109375,$$ the two-sided p-value. Since this exceeds 0.05, you would not reject the hypothesis that the coin is fair.

Row of filled and hollow circles representing k successes out of n trials
A binomial test compares observed successes k in n trials against a hypothesized probability.

Interpreting Your Result

The exact binomial test compares an observed number of successes \(k\) in \(n\) independent trials against a hypothesized success probability \(p\). The p-value answers a single question: if the null hypothesis were true, how likely is an outcome at least as extreme as the one you observed?

Two-sided vs one-sided

A two-sided p-value tests whether the true probability differs from \(p\) in either direction. It sums the probabilities of all outcomes whose likelihood is less than or equal to that of the observed \(k\) (the method used by this calculator and by R's binom.test). Use it when you have no prior reason to expect a high or a low result.

A one-sided p-value tests a directional claim — for example "the true probability is greater than \(p\)." It sums probabilities only in the tail you specified. A one-sided p-value is roughly half of the two-sided value, so choose the direction before seeing the data, never after.

The significance level (alpha)

The threshold \(\alpha\) is the false-positive rate you are willing to tolerate. Common choices are \(\alpha = 0.05\) and the stricter \(\alpha = 0.01\). You compare the p-value to \(\alpha\):

  • If p-value \(\le \alpha\): reject the null hypothesis — the data are inconsistent enough with \(p\) to be called statistically significant.
  • If p-value \(> \alpha\): fail to reject the null hypothesis — the data are compatible with \(p\).

What "fail to reject" does and does not mean

"Fail to reject" means only that you lack sufficient evidence against the null hypothesis. It does not prove the null is true. A small sample can easily produce a non-significant result even when the true probability differs from \(p\); absence of evidence is not evidence of absence. To gauge what the data do support, pair the test with an effect estimate and a confidence interval for the proportion.

Advertisement

Definitions & Glossary

Successes (k)
The observed count of trials with the outcome of interest. An integer with \(0 \le k \le n\).
Trials (n)
The total number of independent Bernoulli trials, each with the same success probability.
Hypothesized probability (p)
The success probability assumed under the null hypothesis, \(0 \le p \le 1\). A coin's fairness, for instance, corresponds to \(p = 0.5\).
Null hypothesis (H₀)
The default claim being tested: the true success probability equals \(p\), i.e. \(H_0:\, \pi = p\).
Alternative hypothesis (H₁)
The claim accepted if H₀ is rejected: \(\pi \ne p\) (two-sided), or \(\pi > p\) / \(\pi < p\) (one-sided).
p-value
The probability, computed under H₀, of obtaining a result at least as extreme as the observed \(k\). Smaller values give stronger evidence against H₀.
Two-sided test
Detects a difference from \(p\) in either direction by summing all outcomes no more probable than the observed one.
One-sided test
Detects a difference in a single, pre-specified direction.
Expected count (np)
The number of successes expected under H₀, \(np\). Comparing \(k\) to \(np\) shows the direction and rough size of the departure.
Significance level (alpha)
The pre-chosen cutoff \(\alpha\) (commonly 0.05 or 0.01) against which the p-value is judged; it is the maximum acceptable probability of a Type I error.

FAQ

When should I use the exact test instead of a z-test? Use the exact binomial test whenever \(n\) is small or expected counts are low, where the normal approximation is unreliable.

What does a small p-value mean? A small p-value (e.g. below 0.05) suggests the observed count is unlikely under the hypothesized probability, providing evidence against it.

Why can the two-sided p-value differ from doubling the one-sided value? The exact two-sided test sums probabilities of all outcomes at least as extreme by probability, which is not always twice the smaller tail when the distribution is skewed.

Last updated: