Binomial Distribution Calculator

Free binomial distribution calculator. Enter n, p, and k for the exact P(X=k), P(X<=k), P(X>=k), mean and variance, plus a bar chart of the distribution.

Advertisement

Binomial distribution calculator for exact, at-most and at-least probabilities

Enter three numbers — n (how many trials), p (the probability any single trial succeeds) and k (the number of successes you care about) — and this calculator returns P(X = k), P(X ≤ k), P(X ≥ k), the mean np, the variance np(1 − p) and the standard deviation. It also draws the full distribution as a bar chart with your chosen k highlighted, and prints the formula with your own numbers substituted in, so you can copy the working into homework or a report.

Everything runs in your browser. Nothing you type is uploaded, and the arithmetic is exact combinatorics rather than a lookup table — the binomial coefficient is built up iteratively (multiply by n − i, divide by i + 1) so that values like C(1000, 500) do not blow past what a factorial can hold.

The four conditions that must hold before binomial applies

This is the part that costs people marks and, in the workplace, costs them a wrong answer they trust. The binomial distribution is not a general-purpose "probability of some successes" formula. It is the exact answer to one narrowly defined situation, and all four of these must be true:

  • A fixed number of trials, decided in advance. You must know n before you start. "I inspected parts until I found a defect" is not binomial — the trial count is itself random there (that is a geometric or negative binomial situation).
  • Each trial has exactly two outcomes. Success or failure, pass or fail, heads or tails, defective or fine. If you have three or more categories you need the multinomial distribution, or you must collapse the categories into one "success" bucket and everything else.
  • A constant success probability p across every trial. If the probability drifts — a machine warming up, a tester getting faster, a lottery drum that is not refilled — the binomial answer is wrong.
  • Independent trials. One result must not change the odds of the next. This is where sampling without replacement breaks the model: drawing 10 cards from a 52-card deck changes the odds after every draw. The strictly correct tool there is the hypergeometric distribution, though binomial is a serviceable approximation when the sample is under roughly a tenth of the population, because the odds barely move.

The calculator cannot check any of this for you. It will happily compute a beautifully precise number for a situation the binomial does not describe. Reading these four conditions against your actual problem is the one step that has to happen in your head.

P(X = k) versus P(X ≤ k) versus P(X ≥ k)

Most wrong binomial answers are not arithmetic errors — they are the right formula answering a slightly different question. The calculator gives all three at once so you can pick the one that matches your sentence:

Wording in the questionWhat you wantCalled
"exactly 3", "precisely 3"P(X = 3)pmf (probability mass)
"at most 3", "3 or fewer", "no more than 3"P(X ≤ 3)cdf (cumulative)
"at least 3", "3 or more"P(X ≥ 3) = 1 − P(X ≤ 2)upper tail
"fewer than 3", "under 3"P(X ≤ 2)cdf at k − 1
"more than 3", "over 3"1 − P(X ≤ 3)upper tail at k + 1

The two rows that catch people are "fewer than" and "more than", both of which are strict inequalities and therefore exclude k itself. If a question says "more than 3 defects", set k to 3, read P(X ≥ 3) — and then realise that is not it, because P(X ≥ 3) includes exactly 3. Either set k to 4 and read P(X ≥ 4), or take 1 minus the P(X ≤ 3) shown at k = 3. Both give the same figure.

Note also that P(X ≤ k) and P(X ≥ k) overlap: they both contain P(X = k), so they add up to more than 1. That is expected, not a bug.

A fully worked example: 20 units, a 5% defect rate

A supplier's process produces a defective unit 5% of the time. You pull 20 units off the line as an audit sample. What is the chance of finding exactly 2 defects, and what is the chance of finding 2 or more?

Set n = 20, p = 0.05, k = 2. The formula is

P(X = k) = C(n, k) · p^k · (1 − p)^(n − k)

Substituting: C(20, 2) = (20 × 19) / 2 = 190. Then p^k = 0.05² = 0.0025. Then (1 − p)^(n − k) = 0.95^18 ≈ 0.3972143. Multiply the three:

190 × 0.0025 × 0.3972143 = 0.1886768

So P(X = 2) ≈ 0.188677, or 18.87%. Roughly a one-in-five chance the audit turns up precisely two bad units.

For "2 or more" you go through the complement, because the tail is infinite in the unhelpful direction — it is far less work to add up the two cases you do not want:

  • P(X = 0) = C(20, 0) · 0.05⁰ · 0.95²⁰ = 1 × 1 × 0.3584859 = 0.3584859
  • P(X = 1) = C(20, 1) · 0.05¹ · 0.95¹⁹ = 20 × 0.05 × 0.3773536 = 0.3773536
  • P(X ≤ 1) = 0.3584859 + 0.3773536 = 0.7358395
  • P(X ≥ 2) = 1 − 0.7358395 = 0.2641605, i.e. 26.42%

The summary statistics for the same setup: mean = np = 20 × 0.05 = 1 defect, variance = np(1 − p) = 20 × 0.05 × 0.95 = 0.95, standard deviation = √0.95 ≈ 0.9747.

That mean of exactly 1 is worth sitting with. The expected number of defects in the sample is one — and yet the single most likely individual outcome is one defect at 37.7%, with zero defects close behind at 35.8%. A clean sample of 20 is not evidence the process improved. It happens more than a third of the time when nothing has changed at all.

Reading the mean and variance

The mean np is where the distribution balances. The variance np(1 − p) tells you how far individual results scatter around it, and it behaves in a way that is easy to remember: it is largest when p = 0.5 and shrinks towards zero as p approaches either 0 or 1. That matches intuition. A coin is maximally unpredictable; an event that almost never happens, or almost always happens, produces results that cluster tightly at one end.

The standard deviation √[np(1 − p)] is the more useful of the two day-to-day, because it is in the same units as the count. For n = 20, p = 0.05 it is about 0.97 defects — so a result of 3 defects is roughly two standard deviations above the expected 1, unusual but not extraordinary. The calculator prints all three.

Where the binomial actually gets used

  • Acceptance sampling and quality control. The classic question: given a known or assumed defect rate, what is the chance a sample of n passes? Run it in reverse to size the sample — increase n until P(X = 0) under an unacceptable defect rate drops low enough that a clean sample really is reassuring.
  • Pass/fail testing. Flaky test suites, hardware burn-in, drug trial responders, screening tests. Anything scored as a run of independent yes/no outcomes.
  • Coin and dice runs. Eight coin flips, at least 6 heads: n = 8, p = 0.5, k = 6 gives P(X = 6) = 28 × 0.5⁸ = 0.109375, plus P(X = 7) = 0.03125 and P(X = 8) = 0.00390625, for P(X ≥ 6) = 0.14453125. Nearly one run in seven — which is why a streak of heads feels significant and mostly is not.
  • Conversion and click counts. With a fixed number of visitors and a stable conversion rate, the count of conversions is binomial. This is the foundation under exact A/B test calculations.
  • Rolling for a specific face. Twelve dice, how many sixes? n = 12, p = 1/6, k = 3: C(12, 3) = 220, giving P(X = 3) ≈ 0.197396, with a mean of exactly 2 sixes and a variance of 12 × (1/6) × (5/6) ≈ 1.6667.

Practical limits and failure modes

InputAcceptedWhat happens outside it
n (trials)whole number, 1 to 1000the field flags and the results hold at the last valid entry
p (probability)0 to 1 inclusiverejected — enter 0.05, not 5
k (successes)whole number, 0 to nrejected; k above n has probability 0 by definition
bar chartdrawn for n ≤ 60hidden above that; the numbers stay exact to n = 1000

The single most common input error is entering p as a percentage. A 5% rate is 0.05. Typing 5 is out of range and the tool will tell you so, but typing 0.5 when you meant 5% will not be flagged — it is a perfectly valid probability, just a tenfold overstatement of your defect rate.

A second trap is treating a very large n with a very small p as if the chart shape were reliable. The mathematics stays exact, but you have moved into territory where the Poisson distribution with λ = np is the conventional model, and where p itself — usually estimated from past data — carries more uncertainty than the sixth decimal place of the output implies. The calculator's precision is a property of the arithmetic, not of your input.

Finally, remember what the discreteness means. X counts whole successes, so the distribution is a set of separate bars, not a curve. There is no P(X = 2.5). For continuous quantities — heights, times, measurement errors — you want the normal distribution calculator instead, which is also the standard approximation to the binomial once n is large and p is not close to either extreme.

Frequently Asked Questions

What is a binomial distribution?+

It is the probability distribution of the number of successes in a fixed number of independent trials, where each trial has the same probability of success. The classic example is counting heads in a set number of coin flips. It is defined by two parameters: n (the number of trials) and p (the probability of success on each trial).

What are the conditions for a binomial experiment?+

Four conditions, often called Bernoulli trials: a fixed number of trials, exactly two possible outcomes per trial (success or failure), a constant probability of success across all trials, and independence between trials. If any condition fails — for example, drawing cards without replacement changes the probability each draw — a different distribution applies.

How do you calculate binomial probability?+

Use P(X = k) = C(n, k) × p^k × (1 − p)^(n − k). Compute the binomial coefficient C(n, k) for the number of arrangements, multiply by p raised to the number of successes, and by (1 − p) raised to the number of failures. This calculator evaluates that formula exactly and also sums it to give cumulative probabilities.

What is the difference between P(X=k), P(X<=k) and P(X>=k)?+

P(X = k) is the probability of exactly k successes — a single term of the formula. P(X <= k) is the cumulative probability of k or fewer successes, found by adding the terms for 0 through k. P(X >= k) is the probability of k or more, equal to 1 minus P(X <= k − 1). This tool reports all three at once.

What are the mean and variance of a binomial distribution?+

The mean (expected number of successes) is np, and the variance is np(1 − p). For example, 100 trials at p = 0.3 have a mean of 30 successes and a variance of 21, giving a standard deviation of about 4.58. These let you summarize the distribution without listing every outcome.

This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results.