A Binomial variable can be written as the sum of \(n\) independent Bernoulli random variables: \(X = \sum_{i=1}^n Y_i\), where \(Y_i \sim \text{Bernoulli}(p)\).
First, find the expectation of a single Bernoulli trial: \[\mathbb{E}[Y_i] = (1 \cdot p) + (0 \cdot (1-p)) = p\]
By the linearity of expectation: \[\mathbb{E}[X] = \mathbb{E}\left[\sum_{i=1}^n Y_i\right] = \sum_{i=1}^n \mathbb{E}[Y_i] = \sum_{i=1}^n p = np\]
Variance of Binomial(n,p)
First, we find the variance of a single Bernoulli trial \(Y_i\): \[\mathbb{E}[Y_i^2] = (1^2 \cdot p) + (0^2 \cdot (1-p)) = p\]\[\text{Var}(Y_i) = \mathbb{E}[Y_i^2] - (\mathbb{E}[Y_i])^2 = p - p^2 = p(1-p)\]
Because the \(n\) Bernoulli trials are independent, the variance of their sum equals the sum of their variances: \[\text{Var}(X) = \text{Var}\left(\sum_{i=1}^n Y_i\right) = \sum_{i=1}^n \text{Var}(Y_i) = n p(1-p)\]
Example 1: Quality Control
Manufacturing plants use the binomial distribution to predict and manage product defects.
Scenario: A factory tests a batch of microchips.
Parameters: Suppose historically, the probability of any single chip being defective is \(p = 0.02\) and the factory tests \(n=50\) microchips. The Binomial parameters are then \(n=50\) and \(p=0.02\).
Problem: Calculate the probability that \(x \le 2\) chips are defective and find the mean and variance of the number of defective chips.
Solutions
Exact Probability \(P(X \le 2) = f(0)+f(1)+f(2)\) = 92.16%
Mean or expected number of defective chips is (50)(.02) = 1
Variance of the number of defective chips is (50)(.02)(.98) = .98.
QC Visualization
library(ggplot2)n <-50p <-0.02df_qc <-data.frame(x =0:8, pmf =dbinom(0:8, size = n, prob = p))df_qc$highlight <-ifelse(df_qc$x <=2, "Target (<=2)", "Other")ggplot(df_qc, aes(x =factor(x), y = pmf, fill = highlight)) +geom_col(width =0.7) +scale_fill_manual(values =c("Target (<=2)"="darkgreen", "Other"="grey70")) +labs(title ="QC Defect Probability Matrix (n=50, p=0.02)",x ="Number of Defective Chips (x)", y ="Probability", fill ="Region") +theme_minimal()
QC Visualization
Example 2: A/B Testing
Digital marketers rely on the binomial distribution to see if website changes actually improve performance.
Scenario: An e-commerce site routes users to a new checkout page design.
Parameters: If the baseline checkout rate is known to be \(p = 0.08\) and the site routes \(n=500\) users to the new checkout page design, then the Binomial parameters are \(n=500\) and \(p=0.08\).
Question: How likely it is to observe \(x \ge 50\) successful purchases by pure chance?