ThisCalculator

Statistics

Binomial Distribution P Value Calculator

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Binomial Distribution P Value Calculator

This calculator performs an exact binomial test: you enter the number of trials, the number of successes, and the hypothesized probability of success, and it returns the one-tailed and two-tailed p-values. The p-value tells you how likely you would see results at least as extreme as yours if the true probability equaled the value you entered. It uses the binomial probability mass function directly, so it works for small samples where the normal approximation fails.

Formula

The binomial probability of observing exactly x successes in n trials, when each trial has success probability p, is:

P(X = x) = C(n, x) · px · (1 − p)n − x

where C(n, x) = n! / (x! (n − x)!) is the binomial coefficient, n is the number of trials, x is the number of successes, and p is the hypothesized probability of success on a single trial. The one-tailed p-value for “at least k successes� is the sum of P(X = i) for i = k to n. The one-tailed p-value for “at most k successes� is the sum for i = 0 to k. The two-tailed p-value is typically computed by doubling the smaller one-tailed p-value (clipped at 1), which is the method used here.

Worked Example

Using the defaults: n = 20 trials, k = 12 successes, p = 0.5.

First, compute P(X ≥ 12). Sum the individual probabilities for x = 12, 13, …, 20:

  • P(X=12) = C(20,12)·0.512·0.58 = 125970 / 1,048,576 ≈ 0.1201
  • P(X=13) = C(20,13)·0.520 = 77520 / 1,048,576 ≈ 0.0739
  • P(X=14) = 38760 / 1,048,576 ≈ 0.0370
  • P(X=15) = 15504 / 1,048,576 ≈ 0.0148
  • P(X=16) = 4845 / 1,048,576 ≈ 0.0046
  • P(X=17) = 1140 / 1,048,576 ≈ 0.0011
  • P(X=18) = 190 / 1,048,576 ≈ 0.0002
  • P(X=19) = 20 / 1,048,576 ≈ 0.0000
  • P(X=20) = 1 / 1,048,576 ≈ 0.0000

Adding these gives P(X ≥ 12) ≈ 0.2517. The one-tailed p-value for “at least 12� is 0.2517. The one-tailed p-value for “at most 12� is 1 − P(X ≥ 13) = 1 − 0.1317 ≈ 0.8683. The two-tailed p-value is 2 × min(0.2517, 0.8683) = 0.5034. The calculator shows these as 0.2517, 0.8683, and 0.5034.

When to Use This Test

Use the binomial test when you have a fixed number of independent trials, each with two outcomes (success/failure), and you want to compare the observed proportion of successes to a hypothesized probability. Common examples:

  • Testing whether a coin is fair (p = 0.5) after 20 flips with 12 heads.
  • Checking if a conversion rate differs from a historical baseline.
  • Evaluating whether a sample of defective items exceeds a claimed defect rate.

This is an exact test, meaning it doesn’t rely on the normal approximation. It is most appropriate when the sample size is small or when p is near 0 or 1, where the normal approximation can be inaccurate.

How to Read the Result

The p-value is the probability of observing a result as extreme as yours, assuming the hypothesized p is true. A small p-value (typically below 0.05) suggests the observed data are unlikely under the null hypothesis, leading to rejection of the null. The one-tailed p-value is used when you have a directional hypothesis (e.g., “at least this many successes�). The two-tailed p-value is used when you are testing for any difference from the hypothesized p, in either direction. The two-tailed value here is the doubled one-tailed value, which is the most common method, but note that some statisticians prefer an alternative that sums the probabilities of all outcomes with probability less than or equal to the observed outcome’s probability.

Common Mistakes and Pitfalls

  • Mixing up one-tailed and two-tailed p-values: Decide before running the test whether your hypothesis is directional. Using a one-tailed p-value when you need two-tailed inflates significance.
  • Entering the wrong number of trials: Trials (n) is the total number of attempts, not the number of successes or failures. Successes (k) cannot exceed n.
  • Using a probability outside 0–1: The hypothesized p must be between 0 and 1 inclusive. Entering 1.5 or −0.2 is invalid.
  • Ignoring the continuity correction: If you use a normal approximation instead of this exact test, you must apply a continuity correction. This calculator avoids that issue.
  • Assuming independence: The binomial test assumes each trial is independent. If trials are not independent, the test is not valid.

Limitations of the Exact Test

The exact binomial test is computationally intensive for very large n (thousands or more), but modern computers handle it easily. The main limitation is that it only tests a single hypothesized p; it does not estimate a confidence interval for the true p. For that, you would use the Clopper-Pearson interval or the Wilson score interval. Also, the two-tailed p-value definition is not unique; different software may give slightly different values. The method used here (doubling the smaller one-tailed p) is the most common, but some packages use the “minimum likelihood� method, which sums probabilities of all outcomes with probability ≤ P(X=k). For most practical purposes, the results are similar.

Comparison with Normal Approximation

For large n and p not too close to 0 or 1, the binomial distribution can be approximated by a normal distribution with mean np and variance np(1−p). The normal approximation is faster and often used in introductory statistics. However, it becomes inaccurate when np or n(1−p) is less than 5, or when p is extreme. The exact test always gives the correct p-value, so it is preferred for small samples or when precision matters. The calculator on this page uses the exact method, so you don’t need to worry about approximation errors.

Frequently Asked Questions

What is the difference between one-tailed and two-tailed p-values?

A one-tailed p-value tests a directional hypothesis, such as “the probability is greater than 0.5.� It sums the probabilities of outcomes as extreme as yours in only one direction. A two-tailed p-value tests any difference from the hypothesized p, in either direction. It is typically double the smaller one-tailed p-value, capped at 1.

Can I use this calculator for a one-sample proportion test?

Yes, the binomial test is exactly that. It compares the observed proportion k/n to a hypothesized p. It is the exact version of the one-sample z-test for proportions, which uses the normal approximation.

What if my number of successes is greater than the number of trials?

That is invalid. The number of successes cannot exceed the number of trials. If you enter such a value, the calculator will not produce a meaningful result. Check your inputs.

How do I choose the hypothesized probability p?

The hypothesized p is the value you want to test against. It could be a historical rate, a theoretical value (like 0.5 for a fair coin), or a claimed proportion. It is not estimated from your data; it is the null hypothesis value.

What is the “two-tailed� p-value when k is exactly the mean?

If k equals the mean np, then the one-tailed p-values are both around 0.5, so the two-tailed p-value is close to 1. This makes sense: an observation exactly at the expected value gives no evidence against the null hypothesis.

Does this calculator work for very large n, like 1000 trials?

Yes, the calculator uses exact binomial coefficients, which are computed efficiently for n up to several thousand. For n beyond that, the numbers become extremely large, but the calculator can still handle it as long as the input is a positive integer. However, for n > 10,000, the normal approximation is usually accurate and faster.

Related

Formula used
in n | Number of trials | - | 20 | 1
in k | Number of successes | - | 12 | 0
in p | Hypothesized probability | - | 0.5 | 0
out p_ge | P(X ≥ k) | - | sum_{i=k}^{n} ncr(n,i)*p^i*(1-p)^(n-i) | 4
out p_le | P(X ≤ k) | - | sum_{i=0}^{k} ncr(n,i)*p^i*(1-p)^(n-i) | 4
out p_two | Two-tailed p-value | - | min(1, 2*min(p_ge, p_le)) | 4

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.