Probability Distributions: Patterns in Randomness
The Factory Quality Problem
You run a factory that produces ball bearings. Each bearing should be exactly 10mm in diameter. But manufacturing isn’t perfect - there’s always some variation. You measure 1000 bearings and get:Difficulty: Beginner
Prerequisites: Modules 1-2 (Describing Data, Probability)
What You’ll Build: Quality control system, prediction intervals
What Is a Probability Distribution?
A probability distribution describes all possible values a random variable can take and how likely each value is. Think of it as a complete map of possibilities. Analogy: A probability distribution is like a city’s terrain map. The peaks show where values cluster (common outcomes), and the valleys show where values are rare. Just as different cities have different landscapes — some flat (uniform), some with a single mountain (normal), some with a long tail running to the east (exponential) — different types of data have different distributional shapes. Learning to “read the terrain” of your data is one of the most valuable skills in ML.Discrete vs Continuous
The Uniform Distribution: Equal Chances
The simplest distribution - every outcome is equally likely.Discrete Uniform: The Fair Die
Continuous Uniform: Random Numbers
- Random weight initialization
- Data augmentation (random crops, rotations)
- Monte Carlo simulations
The Binomial Distribution: Success/Failure Experiments
When you repeat an experiment with two outcomes (success/failure) multiple times. Parameters:- n = number of trials
- p = probability of success on each trial
Mathematical Formula
Where is “n choose k”Visualizing the Binomial Distribution
Real-World Example: Website Conversion
Practice: Quality Control
Practice: Quality Control
- What’s the probability of exactly 0 defects?
- What’s the probability of 3 or more defects?
- How many defects do you expect?
The Normal Distribution: The Bell Curve
This is the most important distribution in statistics. It appears everywhere:- Human heights and weights
- Test scores
- Measurement errors
- Stock price changes
- IQ scores
- (mu) = mean (center of the bell)
- (sigma) = standard deviation (width of the bell)
Mathematical Formula
The 68-95-99.7 Rule (Empirical Rule)
One of the most useful facts in statistics:Z-Scores: Standardizing Any Normal Distribution
A z-score tells you how many standard deviations a value is from the mean.Calculating Probabilities
Why Is the Normal Distribution Everywhere?
The Central Limit Theorem (CLT) explains this magic:Demonstration
Other Important Distributions
Poisson Distribution: Rare Events Over Time
How many customers arrive per hour? How many defects per batch? How many emails per day? Parameter: λ (lambda) = average rate of eventsExponential Distribution: Time Between Events
If events occur at rate λ, how long until the next one?Mini-Project: Quality Control System
Build a complete quality control system for the ball bearing factory.Practice Exercises
Exercise 1: Height Analysis
Solution
Solution
Exercise 2: Server Requests
Solution
Solution
Common Mistakes to Avoid
Interview Questions
Question 1: Normal Distribution Application (Google)
Question 1: Normal Distribution Application (Google)
Question 2: Choosing the Right Distribution (Amazon)
Question 2: Choosing the Right Distribution (Amazon)
- Number of customers arriving per hour
- Whether a user clicks an ad (yes/no)
- Time until a server fails
- Heights of basketball players
Question 3: Central Limit Theorem (Facebook/Meta)
Question 3: Central Limit Theorem (Facebook/Meta)
Question 4: Percentiles in Practice (Netflix)
Question 4: Percentiles in Practice (Netflix)
Practice Challenge
Challenge: Distribution Fitting
Challenge: Distribution Fitting
📝 Practice Exercises
Exercise 1
Exercise 2
Exercise 3
Exercise 4
Key Takeaways
Distribution Types
- Discrete: Countable outcomes (die rolls, counts)
- Continuous: Any value in a range (measurements)
- Each distribution has parameters that define its shape
The Normal Distribution
- Defined by mean (μ) and standard deviation (σ)
- 68-95-99.7 rule for quick calculations
- Appears everywhere due to Central Limit Theorem
Key Distributions
- Uniform: Equal probability (dice, random selection)
- Binomial: Success/failure experiments (conversions, defects)
- Normal: Continuous measurements (heights, errors)
- Poisson: Count of rare events (arrivals, defects)
Z-Scores
- Standardize any normal distribution
- z = (x - μ) / σ
- Allows comparison across different scales
- Standard normal has μ=0, σ=1
Interview Prep: Common Questions
Distribution Interview Questions
Distribution Interview Questions
Poisson: Counting events in continuous time/space where events are rare (website visits, defects). Binomial: Fixed number of trials with binary outcomes (10 coin flips, 100 users converting).Q: How do you check if data is normally distributed?
Visual: histogram, Q-Q plot. Statistical: Shapiro-Wilk test, Anderson-Darling test. Rule of thumb: Check skewness (< 2) and kurtosis (< 7).Q: What is the Central Limit Theorem and why does it matter?
CLT states that sample means approach a normal distribution regardless of population distribution, given large enough samples (n ≥ 30). It’s why we can use normal-based methods even when data isn’t normally distributed.Q: A process has 2% defect rate. What distribution models the number of defects in a batch of 50?
Binomial with n=50, p=0.02. Expected defects = np = 1. Could approximate with Poisson(λ=1) since n is large and p is small.
Common Pitfalls
Connection to Machine Learning
Next: Statistical Inference
Interview Deep-Dive
You are modeling customer support ticket arrivals. How do you decide between Poisson, Binomial, and Normal distributions?
You are modeling customer support ticket arrivals. How do you decide between Poisson, Binomial, and Normal distributions?
- The choice depends on the nature of the data-generating process, not on what the histogram looks like. Poisson is the right choice when you are counting events in a continuous interval (tickets per hour) where events are independent and occur at a roughly constant rate. It has one parameter (lambda, the average rate) and its variance equals its mean.
- Binomial is correct when you have a fixed number of discrete trials each with a binary outcome — for example, “out of 500 customers who contacted us, how many submitted a ticket?” It requires knowing the number of trials and the success probability.
- Normal might be appropriate if you are looking at the average number of tickets per day over many days. By the Central Limit Theorem, the daily averages will be approximately normal even if individual arrivals follow a Poisson process. But you would not use normal for the raw counts because counts cannot be negative, and the normal distribution extends to negative infinity.
- In practice, I would start by checking whether the mean and variance of the ticket counts are roughly equal. If they are, Poisson is a good fit. If the variance is much larger than the mean (overdispersion), I would consider a Negative Binomial distribution instead, which adds a dispersion parameter. Overdispersion is extremely common in real ticket data because arrival rates are not actually constant — they vary by time of day, day of week, and whether there was a product incident.
Explain the Central Limit Theorem to a non-technical product manager, and then explain why it matters for A/B testing.
Explain the Central Limit Theorem to a non-technical product manager, and then explain why it matters for A/B testing.
- For the product manager: “Imagine you survey 100 random customers and compute the average satisfaction score. If you repeated that survey many times, each time with a different random 100 customers, those averages would form a bell curve — even if individual satisfaction scores are not bell-shaped at all. The Central Limit Theorem says that averages of random samples become predictable and bell-shaped as long as your sample is large enough. That is why we can compute a margin of error on any survey or test result.”
- For the technical layer: the CLT states that the sampling distribution of the sample mean converges to a normal distribution as sample size increases, regardless of the population distribution, provided the population has finite variance. The rate of convergence depends on how “non-normal” the underlying distribution is — highly skewed distributions need larger n.
- For A/B testing specifically, the CLT is the entire foundation. When you compare conversion rates between two groups, each conversion rate is a sample mean (of a Bernoulli variable). The CLT guarantees that the difference between these means is approximately normally distributed, which is why you can use a z-test to compute a p-value. Without the CLT, you would need to know the exact distribution of your metric to do any hypothesis testing.
- The practical caveat: the CLT needs “large enough” samples, and “large enough” depends on the distribution. For proportions near 0.5, n=30 is usually fine. For proportions near 0.01 (like conversion rates), you might need n=500 or more before the normal approximation is accurate. This is why very low conversion rate tests need more traffic.
A manufacturing line has a 2% defect rate. You test 500 items and find 18 defects (3.6%). Should you stop the line?
A manufacturing line has a 2% defect rate. You test 500 items and find 18 defects (3.6%). Should you stop the line?
- Before stopping the line (which is expensive), I need to determine if 18 defects in 500 is statistically inconsistent with the expected 2% rate. Under the null hypothesis of 2%, the expected number of defects is 10, and the standard deviation is sqrt(500 x 0.02 x 0.98) = approximately 3.13.
- The z-score for 18 defects is (18 - 10) / 3.13 = 2.56, giving a one-tailed p-value of about 0.005. This is well below the typical 0.05 threshold. So statistically, yes, 18 defects is very unlikely if the true rate is still 2%.
- However, the statistical answer is only half the decision. I would also consider: Is this a sudden spike or a gradual trend? (Check a control chart for the last several batches.) What is the cost of stopping the line versus the cost of shipping defective products? Is there a known assignable cause (like a new material batch or a maintenance event)?
- In a Six Sigma framework, this would trigger an investigation but not necessarily an immediate line stop. I would pull the last 5 batches of data and look at a Shewhart control chart. If the process mean has shifted (as opposed to one unlucky batch), that warrants corrective action. If this is a single batch anomaly, the response might be different — inspect remaining inventory from this batch rather than shutting everything down.