The binomial distribution: counting successes in repeated trials
The binomial distribution models the number of successes in a fixed number of repeated experiments when each trial has only two outcomes
(success/failure) and the success probability stays constant. If you perform \(n\) independent Bernoulli trials, each with success probability \(p\),
and define \(X\) as the number of successes, then we write \(X\sim\mathrm{Bin}(n,p)\).
Common examples include “number of heads in \(n\) coin flips”, “number of defective items in a batch of \(n\)”, or “number of correct answers out of \(n\) questions”
(when independence is a reasonable approximation).
PMF: probability of exactly \(k\) successes
To find the probability of exactly \(k\) successes, we combine two ideas:
(1) there are \(\binom{n}{k}\) different ways to choose which \(k\) trials are successes, and
(2) for any particular pattern with \(k\) successes and \(n-k\) failures, the probability is \(p^k(1-p)^{n-k}\).
Multiplying these gives the probability mass function (PMF):
\[
P(X=k)=\binom{n}{k}p^k(1-p)^{n-k},\qquad k=0,1,\dots,n.
\]
The coefficient \(\binom{n}{k}\) (a binomial coefficient) is often the largest part numerically, which is why calculators compute it using stable methods
(such as log-factorials) when \(n\) is large.
CDF: probability of at most \(k\) successes
Sometimes you need a cumulative probability such as “at most \(k\) successes” or “no more than \(k\) defects”.
This is the cumulative distribution function (CDF):
\[
P(X\le k)=\sum_{x=0}^{k}\binom{n}{x}p^x(1-p)^{n-x}.
\]
The CDF is a sum of PMF values, so it increases from 0 to 1 as \(k\) moves from 0 to \(n\).
Visualizing PMF bars together with the CDF curve helps you see where most of the probability mass lies.
Mean and variance
The binomial distribution has simple summary measures:
\[
\mathbb E[X]=np,\qquad \mathrm{Var}(X)=np(1-p).
\]
The mean \(np\) is the expected number of successes, and the variance tells you how spread out the outcomes are.
When \(p\) is close to 0 or 1, the variance is smaller; when \(p\approx 0.5\), variability is larger for the same \(n\).
Large-\(n\) approximation (university note)
For larger \(n\), exact sums can be computationally heavy, and the binomial distribution is often approximated by a normal distribution with mean \(\mu=np\)
and standard deviation \(\sigma=\sqrt{np(1-p)}\). A common refinement is the continuity correction, which improves accuracy for discrete-to-continuous comparisons,
especially for CDF values.
How to use this tool
Enter \(n\), \(p\), and \(k\), then click Calculate to see \(P(X=k)\), \(P(X\le k)\), and the mean/variance with clear step-by-step work.
The interactive canvas shows PMF bars on top and the CDF line below. You can drag to pan, wheel to zoom, and press Play to sweep the highlighted \(k\)
across the visible range—useful for building intuition about how probability mass accumulates.