SwiftTools

Binomial Distribution Calculator

10 coin flips, exactly 7 heads: about 0.1172 — enter n, p and k below for exact and cumulative probabilities.

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

How the binomial calculator works

The binomial distribution models the number of successes in a fixed number of independent trials, each with the same success probability p. The probability of exactly k successes in n trials is P(X = k) = C(n, k) · p^k · (1 − p)^(n − k), where C(n, k) counts the different ways the k successes can land among the n trials.

For large n, C(n, k) becomes enormous — computing it directly would overflow. This calculator works in log-space instead: it computes ln C(n, k) with the log-gamma function, adds k · ln p + (n − k) · ln(1 − p), and then takes the exponential. That keeps the result exact all the way up to n = 1000.

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

Related tools

Probabilities are easier to compare as percentages — use the Percentage Calculator to turn a decimal result like 0.1172 into 11.72%. And if your result arrives as a fraction such as 120/1024, the Decimal to Fraction Calculator shows its exact fractional form.

Binomial distribution calculator FAQ

When do I use the binomial distribution?

Use it when there is a fixed number of trials, each trial is independent, each trial has exactly two outcomes (success or failure), and the success probability p stays constant across trials — coin flips, pass/fail quality checks, and click-through rates are classic examples.

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

C(10,7) × 0.5^10 = 120/1024 ≈ 0.1172. Set n = 10, p = 0.5, k = 7 in the calculator above to get this result.

What's the difference between P(X=k) and P(X≤k)?

P(X=k) is the probability of exactly k successes. P(X≤k) is cumulative — it sums P(X=k) with the probabilities of all values below k. With 10 coin flips, for example, P(X≤4) = P(X=0) + P(X=1) + P(X=2) + P(X=3) + P(X=4) ≈ 0.377.

When is the normal approximation to the binomial okay?

The common rule of thumb is that both np and n(1−p) should be at least 10 (some textbooks use 5). Then the binomial histogram is close enough to a bell curve for most practical estimates.