Binomial Distribution

Binomial Distribution

Definition

Core Statement

The Binomial Distribution models the number of successes in a fixed number of independent trials, where each trial has the same probability of success. It answers: "If I flip a coin 10 times, what's the probability of getting exactly 6 heads?"


Purpose

  1. Model discrete outcomes with two possibilities (success/failure).
  2. Calculate probabilities for quality control, polling, and A/B testing.
  3. Foundation for proportion tests and confidence intervals for proportions.

When to Use

Use Binomial Distribution When...

  • Fixed number of independent trials (n).
  • Each trial has two outcomes (success or failure).
  • Constant probability of success (p) across trials.
  • Trials are independent.


Theoretical Background

Notation

XBinomial(n,p)

where:

Probability Mass Function (PMF)

P(X=k)=(nk)pk(1p)nk

where (nk)=n!k!(nk)! is the binomial coefficient.

Properties

Property Formula
Mean μ=np
Variance σ2=np(1p)
Standard Deviation σ=np(1p)
Skewness 12pnp(1p)

Approximations

Normal Approximation

For large n and p not near 0 or 1:

Binomial(n,p)N(np,np(1p))

Rule of thumb: Valid if np5 and n(1p)5.

Poisson Approximation

For large n and small p (rare events):

Binomial(n,p)Poisson(λ=np)

Worked Example: Quality Control

Problem

A factory produces light bulbs with a defect rate of 2% (p=0.02).
A quality inspector randomly selects a batch of 20 bulbs (n=20).

Questions:

  1. What is the probability that exactly 2 bulbs are defective?
  2. What is the probability that at least 1 bulb is defective?

Solution:

1. Probability of exactly 2 defects (X=2):

P(X=2)=(202)(0.02)2(0.98)18(202)=20×192=190P(X=2)=190×0.0004×0.695=0.0528

Result: ~5.3% chance of finding exactly 2 bad bulbs.

2. Probability of at least 1 defect (X1):
It's easier to calculate 1P(X=0).

P(X=0)=(200)(0.02)0(0.98)20=1×1×0.6676=0.6676P(X1)=10.6676=0.3324

Result: ~33.2% chance of finding at least one bad bulb in the batch.


Assumptions


Limitations

Pitfalls

  1. Independence Violation (Clustering): If defects happen in clusters (e.g., a machine breaks down and produces 10 bad bulbs in a row), independence is violated. The Binomial model will underestimate the probability of extreme outcomes.
  2. Overdispersion: If the observed variance is significantly larger than np(1p), the data is overdispersed. Use the Beta-Binomial Distribution instead.
  3. Variable p: If the defect rate changes during the day, a simple Binomial model is invalid.


Python Implementation

from scipy.stats import binom
import numpy as np
import matplotlib.pyplot as plt

# Binomial(n=10, p=0.5)
n, p = 10, 0.5
dist = binom(n, p)

# P(X = 6)
prob_6 = dist.pmf(6)
print(f"P(X = 6 | n={n}, p={p}): {prob_6:.4f}")

# P(X <= 7)
prob_le_7 = dist.cdf(7)
print(f"P(X ≤ 7): {prob_le_7:.4f}")

# Visualize PMF
x = np.arange(0, n+1)
plt.bar(x, dist.pmf(x), alpha=0.7, edgecolor='black')
plt.xlabel('Number of Successes (k)')
plt.ylabel('P(X = k)')
plt.title(f'Binomial Distribution (n={n}, p={p})')
plt.xticks(x)
plt.grid(axis='y', alpha=0.3)
plt.show()

R Implementation

# Binomial(n=10, p=0.5)
n <- 10
p <- 0.5

# P(X = 6)
dbinom(6, size = n, prob = p)

# P(X <= 7)
pbinom(7, size = n, prob = p)

# Random sample
rbinom(20, size = n, prob = p)

# Visualize
x <- 0:n
plot(x, dbinom(x, size = n, prob = p), type = "h", lwd = 3,
     xlab = "Number of Successes", ylab = "Probability",
     main = paste("Binomial(n=", n, ", p=", p, ")", sep=""))
points(x, dbinom(x, size = n, prob = p), pch = 16, col = "blue")

Interpretation Guide

Scenario Interpretation
n=100, p=0.5 Mean = 50. Typical coin flip scenario. Symmetric distribution.
n=1000, p=0.001 Rare Events. Distribution is highly right-skewed. Better modeled by Poisson.
P(X 1) "At Least One" Risk. Even with low p, large n makes failure likely.
Spread vs Mean Standard Deviation σn. Percentage error decreases as n grows.