Binomial Distribution Calculator

Binomial probability calculator with a live bar chart: exact P(X=k), cumulative, inverse and the normal approximation with continuity correction.

Runs in your browser

Whole-number outcomes only · n up to 10,000,000 · exact sums switch to the incomplete beta above n = 100,000

Exact binomial probabilities with a live bar chart: set the number of trials and the success probability, then read P(X = k), P(X ≤ k) and P(X ≥ k) together with the normal approximation.

See other distributions →

Real-world presets:
Binomial bar chart for n = 20. 10 bars are highlighted, total probability 0.588099.Normal approximation510150.588099

P(X ≤ 10) = 0.588099 · Normal approximation

Parameters

What to calculate

Type in either box — the other one is solved for you.

Boundary

Adds ±0.5 when approximating a discrete distribution with the normal curve.

Result

P(X ≤ 10)
0.588099 P(X ≤ 10) = Σ C(20, i) · 0.5^i · 0.5^(20−i) = 0.588099

Related probabilities

P(X ≤ x)
0.588099
P(X ≥ x)
0.588099
P(X = x)
0.176197
P(X < x)
0.411901
P(X > x)
0.411901
Two-tail probability
1.000000
z-score
0
Percentile
58.81th percentile

Distribution summary

Mean
10
Variance
5
Standard deviation
2.236068
Median
10
Mode
10
Skewness
0
Excess kurtosis
-0.100000

Normal approximation

MethodResultError
Exact0.588099—
Approximation0.5000008.810e-2
With continuity correction0.5884683.698e-4

Probability table

kP(X = k)P(X ≤ k)P(X ≥ k)
30.0010870.0012880.999799
40.0046210.0059090.998712
50.0147860.0206950.994091
60.0369640.0576590.979305
70.0739290.1315880.942341
80.1201340.2517220.868412
90.1601790.4119010.748278
100.1761970.5880990.588099
110.1601790.7482780.411901
120.1201340.8684120.251722
130.0739290.9423410.131588
140.0369640.9793050.057659
150.0147860.9940910.020695
160.0046210.9987120.005909
170.0010870.9997990.001288

Same calculation in code

from scipy.stats import binom
binom.cdf(10, 20, 0.5)  # 0.5880985260009738

Turn on the continuity correction to see why ±0.5 matters — at n = 100, p = 0.5 it cuts the approximation error by about twenty times.

Four conditions a binomial situation must meet

The number of trials n is fixed in advance. Each trial has exactly two outcomes. The success probability p is the same on every trial. The trials are independent. Twenty coin flips, 1,000 units inspected at a 1% defect rate, 50 free throws by a 78% shooter — all four conditions hold, and the count of successes follows a binomial distribution.

The interesting cases are the ones that fail. Drawing 5 cards from a deck without replacement breaks independence — p changes with every draw — so that is hypergeometric, not binomial. Ten shots by ten different players breaks the constant-p condition; that is a Poisson binomial. "Keep rolling until you get a six" has no fixed n at all; that is geometric.

  • Sampling without replacement is close enough to binomial when the sample is a small slice of the population — the usual rule is n ≤ 5% of the population size. Auditing 100 invoices out of 50,000 is safely binomial; auditing 100 out of 300 is not.

The formula, worked through once

P(X = k) = C(n,k) · pᵏ · (1−p)ⁿ⁻ᵏ. The last two factors are the probability of one particular sequence with k successes; C(n,k) counts how many sequences have exactly k. For 20 coin flips and k = 10: C(20,10) = 184,756 and 0.5²⁰ = 9.5367e-7, so P = 184,756 × 9.5367e-7 = 0.176197.

Note that the most likely single outcome is still under 18%. That surprises people who expect "10 heads out of 20" to be common; it is the most probable individual count, but there are 21 possible counts and the mass is spread across them. The mode is ⌊(n+1)p⌋, the mean is np = 10 and the standard deviation √(np(1−p)) = 2.2361, so most results land between 8 and 12.

The binomial is symmetric only when p = 0.5. Its skewness is (1−2p)/√(np(1−p)), so n = 20 with p = 0.1 has skewness 0.5963 and a visible right tail: mean 2, standard deviation 1.3416, and a long thin tail towards 8 or 9. That asymmetry is exactly what the normal approximation struggles with.

Exactly, at most, at least — and “at least one”

P(X = k) is a single bar; P(X ≤ k) adds every bar from 0 to k; P(X ≥ k) adds from k up to n. For 20 coin flips: P(X = 10) = 0.176197, P(X ≤ 10) = 0.588099 and P(X ≥ 10) = 0.588099 — the two cumulatives are equal here only because they both include the k = 10 bar, and 0.588099 + 0.588099 − 0.176197 = 1 exactly.

Translate the words carefully, because the wording is where the errors are. "At least k" is P(X ≥ k); "more than k" is P(X ≥ k+1); "at most k" is P(X ≤ k); "fewer than k" is P(X ≤ k−1). Getting 15 or more heads out of 20 has probability 0.020695, but getting more than 15 is only 0.005909 — a factor of 3.5 between two phrasings people use interchangeably.

"At least one" has a shortcut worth memorising: P(X ≥ 1) = 1 − (1−p)ⁿ. With a 2% drop rate and 100 tries that is 1 − 0.98¹⁰⁰ = 0.867380, so a 2% chance repeated 100 times is not a guarantee — 13% of players still get nothing. Turned around, reaching a 95% chance of at least one success at p = 0.02 needs ln(0.05)/ln(0.98) = 148.3, so 149 tries.

The normal approximation and the ±0.5 correction

A binomial with enough mass in the middle looks like a normal with μ = np and σ = √(np(1−p)). The usual admission test is np ≥ 5 and n(1−p) ≥ 5; this page checks it and marks the approximation as unreliable when it fails, rather than printing a number that looks fine.

The correction exists because bars have width and a curve does not. A bar at k covers the interval from k − 0.5 to k + 0.5, so P(X ≤ k) should be read as the area up to k + 0.5, and P(X ≥ k) as the area from k − 0.5. Skipping that shift throws away half a bar at the boundary, and near the centre half a bar is a lot.

Measured: at n = 100, p = 0.5, the exact P(X ≤ 60) is 0.982400. The plain approximation gives 0.977250 (error 5.15e-3); with the correction it gives 0.982136 (error 2.64e-4) — about twenty times closer, from one arithmetic shift.

But the correction cannot rescue an approximation that should not have been used. At n = 20, p = 0.05 — np = 1, well under the threshold — the exact P(X ≤ 1) is 0.735840 while the corrected normal gives 0.696021, still 4 percentage points off. When the condition fails, use the exact answer; it is right there on the same screen.

Binomial, Poisson or hypergeometric?

When n is large and p is small, the Poisson with λ = np is an excellent stand-in. At n = 1,000 and p = 0.01 the exact binomial P(X ≤ 15) is 0.952129 and the Poisson gives 0.951260 — a difference of 8.7e-4, invisible in any practical decision. The rules of thumb are n ≥ 20 with p ≤ 0.05, or n ≥ 100 with np ≤ 10.

Poisson also applies where the binomial cannot: when there is no n to count. "Calls per hour", "defects per square metre", "typos per page" have events but no trials, so λ is the only parameter and both the mean and the variance equal it. If your data has a variance much larger than its mean, neither model fits and you are looking at overdispersion.

Hypergeometric is the one to reach for when you are sampling without replacement from a finite lot and the sample is a large fraction of it — 10 units drawn from a batch of 40. The binomial will understate the variance there, because it assumes the pool never runs down.

Quality control, A/B tests and drop rates

Acceptance sampling. If a supplier claims a 1% defect rate and you inspect 1,000 units, the count of defects has mean 10 and standard deviation 3.15. P(X ≥ 16) = 0.047871, so a rule of "reject the lot at 16 or more defects" rejects a genuinely 1% lot about 4.8% of the time — that is the producer’s risk, and it is a number you choose rather than discover.

A/B tests. Conversions are binomial counts, so the question "we saw 47 conversions out of 500 instead of the usual 8%" becomes a tail probability. With n = 500 and p = 0.08 the mean is 40 and σ = 6.07, so 47 is barely more than one standard deviation out — not evidence of anything. Working in counts rather than percentages makes small-sample noise visible.

Drop rates and lotteries. A 0.6% item pulled 100 times gives P(X ≥ 1) = 1 − 0.994¹⁰⁰ = 0.4522 — under half. Two hundred pulls reach 0.6999, and the median number of pulls needed is ln(0.5)/ln(0.994) ≈ 115. The same arithmetic answers "how many tickets do I need for a 90% chance", which is why the at-least-one form is the one people actually want.

Computing exactly at very large n

C(n,k) overflows fast: C(100,50) is about 1e29 and C(1000,500) about 2.7e299, right at the edge of a 64-bit float. The page never forms the binomial coefficient directly — it works with log-gamma and exponentiates at the end, so the intermediate values stay in range and P(X = k) is accurate even when the coefficient itself is not representable.

Cumulative probabilities are summed term by term up to n = 100,000. Above that the sum would need too many terms, so the regularised incomplete beta function I₁₋ₚ(n−k, k+1) is evaluated instead — the same identity scipy uses. At n = 10,000,000 the relative error stays around 4e-9, and n is accepted up to that limit.

The bar chart follows a different limit: one bar per outcome up to 200 outcomes, after which bars are grouped so the picture stays readable and the page says the chart is binned. The numbers in the result panel are always the exact ones — only the drawing is summarised.

How to use

  1. Set the number of trials (n) and the success probability (p).
  2. Enter k to get P(X = k), P(X ≤ k) and P(X ≥ k) at once.
  3. Toggle the boundary between inclusive (≤) and exclusive (<) — for discrete data they differ.
  4. Turn on continuity correction to compare the exact answer with the normal approximation.

FAQ

What is the difference between a binomial and a Bernoulli trial?

A Bernoulli trial is a single yes/no experiment with probability p — the binomial with n = 1. The binomial counts successes across n independent Bernoulli trials, so its mean is n times the Bernoulli mean (np) and its variance n times the Bernoulli variance (np(1−p)). Set n = 1 on this page and you get the Bernoulli case: two bars, at 1−p and p.

Can n or k be a decimal?

Neither is meaningful — you cannot have 20.5 trials or 10.5 successes — so the calculator rounds n to the nearest whole number and tells you it did, and treats a fractional k as the whole number below it (k = 10.7 is read as 10, because P(X ≤ 10.7) and P(X ≤ 10) are the same event for a whole-number variable). If your quantity really is continuous, you want the normal distribution instead.

What if the success probability changes between trials?

Then it is not binomial. Ten shots by ten different players, or A/B traffic where the conversion rate drifts through the week, follow a Poisson binomial distribution, which has no simple closed form. Two workable approximations: if the individual probabilities are close together, use the binomial with their average; if there are many trials with small probabilities, use a Poisson with λ = Σpᵢ. For an exact answer, simulate.

How do I find n or p when I already know the probability?

The inverse mode solves for k, not for n or p, because those two have no closed-form inverse. For the "at least one" case there is an exact formula: n = ln(1 − target)/ln(1 − p), so a 95% chance of at least one success at p = 0.02 needs ln(0.05)/ln(0.98) = 148.3 → 149 trials. For anything else, move the n or p slider and watch the probability — the search converges in a few seconds.

Why do the exact and approximate answers differ in the far tail?

The np ≥ 5 rule keeps the approximation honest near the centre, not out in the tail. The normal curve has thinner tails than a skewed binomial, so relative error grows quickly as you move out: an approximation that is accurate to 3 decimals at the mean can be wrong by an order of magnitude at P ≈ 1e-6. For rare-event work — defect escapes, safety margins — read the exact value, which this page always shows alongside the approximation.

How do I do the same calculation in Excel or Python?

Excel: =BINOM.DIST(k, n, p, FALSE) for P(X = k) and TRUE for P(X ≤ k); =BINOM.INV(n, p, q) for the inverse. Python: from scipy.stats import binom, then binom.pmf(k, n, p), binom.cdf(k, n, p) and binom.ppf(q, n, p). R: dbinom, pbinom, qbinom. Every result on this page prints the matching line for all three, so you can paste it straight into a sheet or a notebook.

Related tools

More AI & Data tools: AI & Data

Send feedback

Found a bug or have an idea? Tell us — it helps make the tools better.

Only needed if you would like a reply.

Page: /ai/binomial-distribution-calculator/