Binomial Distribution Calculator

Binomial Distribution Calculator

Find the exact chance of exactly, at most, at least or between k successes in n independent trials, with the mean, standard deviation and mode, the whole distribution charted, and the normal and Poisson approximations beside the exact answer.

Every figuretap a card to copy its value
Exact answer and the two approximations

Distribution

Every outcome

P(X = j) = C(n, j) × p^j × (1 − p)^(n − j). Cumulative answers add these terms from the smallest up, each found from logarithms, so a million trials work without overflow or rounding loss. Mean = np, variance = np(1 − p), mode = the whole part of (n + 1)p. The normal approximation widens the range by 0.5 at each end; the Poisson uses λ = np, or n(1 − p) on the failures when p is above 0.5. Trials are assumed independent with the same p. The CSV, image and printed report contain the values you entered, nothing preloaded.

How to use this tool

Enter the number of trials, the chance of success on each one and the count you care about. Type the chance as a decimal (0.25), a percentage (25%) or a fraction (1/6), then pick exactly, at most, fewer than, at least, more than, or a range between two counts. The answer comes as a percentage, a decimal, odds and, when p is a simple fraction, the exact fraction, and the cards below give all five one sided versions at once.

The input people most often get wrong is the condition. “At least 7” includes 7 and “more than 7” does not; for 10 coin flips that is 17.19% against 5.47%. The other trap is what counts as a success. It is whatever you are counting, not what you hope for: in a defect check a defective part is the success, and p is the defect rate.

What the calculation is doing

One particular sequence of n trials with k successes has probability p^k × (1 − p)^(n − k), and C(n, k) = n! ÷ (k! (n − k)!) counts the sequences, so P(X = k) = C(n, k) × p^k × (1 − p)^(n − k). Cumulative answers add these terms. The mean is np, the variance np(1 − p), and the mode is the whole part of (n + 1)p, with two equally likely counts when (n + 1)p is a whole number.

Done naively, the formula fails twice. Factorials overflow: 171! is about 1.24 × 10^309, past the largest number a browser can hold, so each term is worked out from logarithms with the saddle point method that R uses for its binomial function. And subtraction loses tails: P(X ≥ 6,000) in 10,000 flips is about 8.7 × 10^−88 percent, but 1 − P(X ≤ 5,999) comes out as exactly zero because the answer sits below the 16th digit. The calculator adds each tail directly, smallest terms first, and never subtracts from 1.

Left: three bar charts of the binomial distribution with p = 0.1 and 10, 30 and 100 trials, each overlaid with a normal curve, showing the largest error of the normal approximation in P(X ≤ k) falling from 4.96 points at np = 1 to 3.09 points at np = 3 and 1.75 points at np = 10. Right: a table of P(X ≤ 3) with a mean of 5 held fixed, where the exact binomial rises from 17.19% at n = 10, p = 0.5 to 26.43% at n = 1,000, p = 0.005 while the Poisson value stays at 26.50%
More trials help the normal curve, and a smaller chance per trial helps the Poisson. Even at np = 10, where textbooks call the normal approximation safe, it still misses a cumulative probability by 1.75 points.

When the normal and Poisson shortcuts are good enough

Before computers nobody added a thousand terms by hand, so two shortcuts took over. The normal approximation swaps the bars for a bell curve with the same mean and standard deviation. Each bar is one unit wide, so P(X ≥ 7) is the area from 6.5 upward; that half step is the continuity correction. For 7 or more heads in 10 flips it gives 17.14% against an exact 17.19%. Without it the answer is 10.30%.

How many trials is enough depends on the shape. Penn State’s probability course accepts np and n(1 − p) of at least 5; its applied course asks for 10, because a small expected count makes the distribution lopsided. Guessing on 20 four choice questions has np = 5, and the chance of at least 10 right is 1.39% exactly but 1.01% by the curve, 27% too low. Tails are where the curve is weakest even with plenty of trials: for 6,000 or more heads in 10,000 flips the normal answer is about four times the exact one.

The Poisson approximation, with λ = np, suits many trials and a rare success. Penn State’s rule of thumb is n ≥ 20 with p ≤ 0.05, or n ≥ 100 with p ≤ 0.10. In the NIST acceptance sampling example, a lot that is 3% defective passes when a sample of 52 holds at most 3 defectives: 92.95% exactly, 92.66% by Poisson and 94.26% by the normal curve.

Cumulative probabilities for 20 trials

P(X ≤ k) for 20 trials, rounded to four decimals in the style of a printed table. For “at least k”, take 1 minus the entry for k − 1, or open the calculator for the unrounded figure.

kp = 0.05p = 0.1p = 0.25p = 0.5p = 0.75p = 0.9
00.35850.12160.00320.00000.00000.0000
10.73580.39170.02430.00000.00000.0000
20.92450.67690.09130.00020.00000.0000
30.98410.86700.22520.00130.00000.0000
40.99740.95680.41480.00590.00000.0000
50.99970.98870.61720.02070.00000.0000
61.00000.99760.78580.05770.00000.0000
71.00000.99960.89820.13160.00020.0000
81.00000.99990.95910.25170.00090.0000
91.00001.00000.98610.41190.00390.0000
101.00001.00000.99610.58810.01390.0000
111.00001.00000.99910.74830.04090.0001
121.00001.00000.99980.86840.10180.0004
131.00001.00001.00000.94230.21420.0024
141.00001.00001.00000.97930.38280.0113
151.00001.00001.00000.99410.58520.0432
161.00001.00001.00000.99870.77480.1330
171.00001.00001.00000.99980.90870.3231
181.00001.00001.00001.00000.97570.6083
191.00001.00001.00001.00000.99680.8784
201.00001.00001.00001.00001.00001.0000

A worked example you can check on paper

The calculator opens on 10 flips of a fair coin and the chance of at least 7 heads. Each sequence of 10 flips has probability 0.5 to the power 10 = 1/1,024. The number of sequences with exactly 7 heads is C(10, 7) = 10 × 9 × 8 ÷ (3 × 2 × 1) = 120; with 8 heads there are 45, with 9 there are 10 and with 10 there is 1. That makes 176 sequences, and 176 ÷ 1,024 = 11/64 = 0.171875, or 17.19%.

The mean is np = 10 × 0.5 = 5 and the standard deviation is √(10 × 0.5 × 0.5) = √2.5 = 1.5811. With the continuity correction the normal approximation is P(Z ≥ (6.5 − 5) ÷ 1.5811) = P(Z ≥ 0.9487) = 17.14%, close because p = 0.5 keeps the bars symmetric. The Poisson approximation with λ = 5 gives 23.78%, well off, because a 50% chance is anything but rare.

Mistakes that catch people out

Mixing up “at least” and “more than”. P(X ≥ 7) includes 7 and P(X > 7) starts at 8. For 10 fair flips they are 17.19% and 5.47%.

Using the binomial when p changes. Drawing parts from a small batch without putting them back changes the defect rate after every draw. When the sample is a large share of the lot, use the hypergeometric distribution.

Leaving out the continuity correction. Measuring the normal area from 7 rather than 6.5 turns 17.14% into 10.30% for the coin example, against an exact 17.19%.

Trusting a rule of thumb in the tails. Meeting np ≥ 10 says the middle of the distribution is bell shaped. It says little about a 1% tail.

Reading a rounded table for a rare event. An entry of 1.0000 is not certainty, and 1 minus it is not zero. Use the exact figure for anything below about 1%.

Popular calculations

Each opens the calculator with those numbers filled in, and they can be changed once it is open.

Coin flips

Guessing on a multiple choice test

Defects and acceptance sampling

Foul shots in basketball

100 trials and more

How this was checked

A separate program added the terms as exact fractions with big integers for 1,500 random cases with up to 300 trials, eleven simple values of p and all six conditions; the largest relative difference was 5 parts in ten million million, for answers as small as 10^−692. The same exact method at 10,000 trials, p = 1/2 and 3/10, agreed to 9 parts in ten million million, down to P(X ≥ 9,000) = 4.924 × 10^−1601. For 110 combinations of n and p up to 100,000 trials the terms add to 1 within 3.2 × 10^−15, and at a million trials the results match a separate incomplete beta calculation to about 2 parts in a billion.

All 59 entries taken from the University of Houston cumulative binomial table match to four decimals. The NIST/SEMATECH operating characteristic table for a sample of 52 with acceptance number 3 lists 12 values: 10 match to three decimals, and at 4% and 5% defective the handbook prints 0.845 and 0.739 where exact arithmetic gives 0.8460 and 0.7383. Penn State STAT 414 examples are reproduced: 0.246 for 5 heads in 10 flips, 0.0537 for 8 or 9 heads, and 0.258 exact against 0.265 Poisson for the bulbs. Its normal figures of 0.251, 0.0549 and 0.1575 come out exactly when z is rounded to two decimals, as with a printed z table; unrounded they are 0.2482, 0.0547 and 0.1580. Every address listed above was opened and checked for a distinct title, the right answer and clean exports at desktop and phone widths.

Common questions

What is the probability of getting exactly 5 heads in 10 coin flips?

252 out of 1,024, or 24.61%. There are C(10, 5) = 252 orders in which 5 heads and 5 tails can fall, and each order has a chance of 1 in 1,024. Five heads is the most likely result, yet it happens less than a quarter of the time.

How do you work out the probability of at least k successes?

Add P(X = j) for every j from k to n. For at least 7 heads in 10 flips that is 120 + 45 + 10 + 1 = 176 orders out of 1,024, or 17.19%. The shortcut 1 − P(X ≤ k − 1) works for large answers, but for very small tails the subtraction loses the digits that matter.

What are the mean and standard deviation of a binomial distribution?

The mean is np and the standard deviation is the square root of np(1 − p). For 100 fair coin flips that is 50 heads, give or take 5, and the chance of landing between 40 and 60 heads inclusive is 96.48%.

When can you use the normal approximation to the binomial?

When np and n(1 − p) are both at least 10, the safer rule, or at least 5, the looser one, and with the continuity correction: move each boundary half a step outward. Even then it is weakest for small tail chances.

What are the chances of passing a multiple choice test by guessing?

With 20 questions of 4 choices each, guessing at least 10 right has a chance of 1.39%, about 1 in 72, and at least 12, a 60% pass mark, 0.0935%, about 1 in 1,069. The expected score from guessing is 5.

What is the difference between the binomial and the Poisson distribution?

The binomial counts successes in a fixed number of trials, so it never exceeds n. The Poisson counts events with no upper limit. With many trials and a small p they nearly agree with λ = np: for 100 bulbs at 5% defective, at most 3 defective is 25.78% exactly and 26.50% by Poisson.

Related Calculators and Reference