The binomial distribution is a discrete probability distribution that models the number of successes in a fixed number of independent trials, each with the same probability of success.
A random variable \(X\) follows a binomial distribution with parameters \(n\) (number of trials) and \(p\) (probability of success) if
\[
X \sim \text{Binomial}(n, p) \quad \text{or}
\quad X \sim \mathcal{B}(n, p).
\]
Interpretation: We choose \(k\) positions out of \(n\) trials for successes (\(\binom{n}{k}\) ways), then assign probability \(p^k\) to these successes and \((1-p)^{n-k}\) to the remaining failures.
Special case: When \(n = 1\) we recover the Bernoulli distribution, with \(\mathbb{P}(X = 1) = p\) and \(\mathbb{P}(X = 0) = 1 - p\).
Plotting code
import numpy as npimport matplotlib.pyplot as pltimport seaborn as snsfrom scipy.stats import binomsns.set_style('whitegrid')sns.set_palette('Set2')n, p =20, 0.3k = np.arange(0, n +1)pmf = binom.pmf(k, n, p)fig, ax = plt.subplots(figsize=(7, 4))ax.bar(k, pmf, color='#4c72b0', alpha=0.8)ax.axvline(n * p, color='#c44e52', ls='--', lw=1.5, label=r'$\mathbb{E}[X] = np$')ax.set_xlabel('$k$')ax.set_ylabel(r'$\mathbb{P}(X = k)$')ax.set_title(r'Binomial PMF $\mathcal{B}(20,\ 0.3)$')ax.legend()plt.show()
Probability mass function of \(\text{Binomial}(20, 0.3)\).
3 Key Properties
The expectation and variance of \(X \sim \text{Binomial}(n, p)\) are