Skip to main content
Probability Distributions

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:
Output:
If you plot these measurements, something magical appears:
A bell curve emerges. This isn’t coincidence - it’s one of the most profound patterns in nature.
Key Probability Distributions for ML
Estimated Time: 3-4 hours
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

Discrete vs Continuous Distributions

The Uniform Distribution: Equal Chances

The simplest distribution - every outcome is equally likely.

Discrete Uniform: The Fair Die

Output:
Each face appears roughly 16.67% (1/6) of the time.
Uniform Distribution - Dice and Lottery

Continuous Uniform: Random Numbers

ML Applications:
  • 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
Question: If you flip a coin 10 times, what’s the probability of getting exactly 7 heads?

Mathematical Formula

P(X=k)=(nk)pk(1p)nkP(X = k) = \binom{n}{k} p^k (1-p)^{n-k} Where (nk)=n!k!(nk)!\binom{n}{k} = \frac{n!}{k!(n-k)!} is “n choose k”

Visualizing the Binomial Distribution

Real-World Example: Website Conversion

A factory produces items with a 2% defect rate. In a batch of 50 items:
  1. What’s the probability of exactly 0 defects?
  2. What’s the probability of 3 or more defects?
  3. 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
Parameters:
  • μ\mu (mu) = mean (center of the bell)
  • σ\sigma (sigma) = standard deviation (width of the bell)

Mathematical Formula

f(x)=1σ2πe12(xμσ)2f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}
Normal Distribution Formula and Shape

The 68-95-99.7 Rule (Empirical Rule)

One of the most useful facts in statistics:
68-95-99.7 Rule Applied to Heights

Z-Scores: Standardizing Any Normal Distribution

A z-score tells you how many standard deviations a value is from the mean. z=xμσz = \frac{x - \mu}{\sigma}

Calculating Probabilities


Why Is the Normal Distribution Everywhere?

The Central Limit Theorem (CLT) explains this magic:
Central Limit Theorem: When you add up many independent random variables, their sum tends toward a normal distribution - regardless of the original distributions.

Demonstration

This is why heights are normally distributed: Height is determined by thousands of genes, each adding a small random effect. Sum of many small random things = normal distribution.
ML Application — Why Batch Normalization Works: The Central Limit Theorem is the hidden reason batch normalization is so effective in deep learning. Each layer in a neural network sums many weighted inputs — and by CLT, those sums tend toward normality. Batch normalization exploits this by re-centering and re-scaling activations to a standard normal at each layer, stabilizing training and allowing higher learning rates. When someone asks “why does batch norm help?”, the CLT is the statistical foundation of the answer.
Statistical Mistake in ML — Assuming Normality of Features: Many ML practitioners apply z-score standardization and assume their features are normally distributed. But real-world features like income, click counts, and session durations are often heavily skewed. Before standardizing, plot your distributions. For right-skewed data, a log transform before standardization often dramatically improves model performance — especially for linear models and neural networks that implicitly assume symmetric inputs.

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 events P(X=k)=λkeλk!P(X = k) = \frac{\lambda^k e^{-\lambda}}{k!}

Exponential 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.
Output:

Practice Exercises

Exercise 1: Height Analysis

Exercise 2: Server Requests


Common Mistakes to Avoid

Mistake 1: Assuming Everything is NormalNot all data follows a normal distribution. Income data is heavily right-skewed. Time-to-event data often follows exponential distributions. Always visualize your data before assuming normality.
Mistake 2: Misusing the 68-95-99.7 RuleThis rule ONLY applies to normal distributions. Applying it to skewed data will give wrong answers. For non-normal data, use Chebyshev’s inequality: at least 75% of data is within 2 std devs, regardless of distribution shape.
Mistake 3: Confusing PDF and CDFThe PDF gives the relative likelihood at a point (technically, density). The CDF gives the probability of being less than or equal to a value. P(X = exact value) is always 0 for continuous distributions.

Interview Questions

Question: Website response times follow a normal distribution with mean 200ms and std dev 50ms. What percentage of requests take more than 300ms?
Answer: About 2.3%
The 68-95-99.7 rule gives us a quick check: 300ms is 2 standard deviations above mean, so roughly 2.5% should be above that.
Question: You’re modeling these scenarios. Which distribution would you use for each?
  1. Number of customers arriving per hour
  2. Whether a user clicks an ad (yes/no)
  3. Time until a server fails
  4. Heights of basketball players
Answer:
  1. Poisson - Counts of events in fixed intervals
  2. Bernoulli (single trial) or Binomial (many users) - Binary outcomes
  3. Exponential - Time until an event (memoryless process)
  4. Normal - Continuous measurements of natural phenomena
For height, you might also consider that basketball players are selected to be tall, so it could be a truncated normal!
Question: User session times are heavily right-skewed (not normal). You calculate the average session time each day for 30 days. What distribution does the sample mean follow?
Answer: Approximately normal!Thanks to the Central Limit Theorem, the sampling distribution of the mean will be approximately normal regardless of the underlying distribution shape, as long as:
  • Sample size is sufficiently large (n ≥ 30 is a common rule of thumb)
  • The original distribution has finite variance
This is why we can use confidence intervals and hypothesis tests based on the normal distribution even when the underlying data isn’t normal.
Question: Video start times follow a log-normal distribution (right-skewed). The P50 is 1.2 seconds and P95 is 4.8 seconds. What does this tell you about user experience?
Answer:
  • Half of users experience start times of 1.2s or less (good!)
  • 5% of users wait more than 4.8 seconds (potentially frustrating)
  • The ratio P95/P50 = 4 indicates significant variability
For right-skewed metrics like latency, the P95 or P99 is often more important than the mean because it captures the experience of the “unlucky” users. A 4x difference between median and P95 suggests there are edge cases worth investigating (slow CDNs, distant users, etc.).

Practice Challenge

You have real website session data. Determine which distribution best fits it:
Solution:

📝 Practice Exercises

Exercise 1

Work with normal distribution and z-scores

Exercise 2

Apply binomial distribution to A/B testing

Exercise 3

Model customer arrivals with Poisson distribution

Exercise 4

Real-world: Quality control with distributions

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

Q: When would you use Poisson vs Binomial distribution?
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

Distribution Mistakes to Avoid:
  1. Assuming Normality - Always check; many real-world distributions are skewed or heavy-tailed
  2. Confusing Parameters - Variance (σ²) vs Standard Deviation (σ); Population vs Sample
  3. Ignoring Distribution Shape - Mean/std alone don’t fully describe a distribution; visualize first
  4. Wrong Distribution Choice - Using normal for bounded data, using binomial for continuous outcomes
  5. CLT Misapplication - CLT applies to sample means, not individual observations

Connection to Machine Learning

ML Connection: When you see “Gaussian” in ML papers, it means “normal distribution.” Gaussian processes, Gaussian mixture models, and Gaussian noise all rely on properties of the normal distribution you just learned!
Coming up next: We’ll learn about Statistical Inference - how to draw conclusions about entire populations from just samples. This is how polls predict elections and A/B tests drive decisions.

Next: Statistical Inference

Learn to draw conclusions from limited data

Interview Deep-Dive

Strong Answer:
  • 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.
Follow-up: Your ticket data shows variance that is 4x the mean. What does this tell you and how do you handle it?Variance much larger than the mean is overdispersion, and it means the Poisson assumption is violated. This typically happens because the arrival rate itself is not constant — it varies over time or across customer segments. Using Poisson in this situation would underestimate the probability of extreme counts (many tickets or zero tickets) and give overly narrow prediction intervals. The fix is to use a Negative Binomial distribution, which explicitly models this extra variation. Alternatively, you can build a hierarchical model: the arrival rate lambda follows a Gamma distribution across time periods, and conditional on lambda, counts follow a Poisson. This is actually mathematically equivalent to the Negative Binomial and gives you a richer understanding of what is driving the overdispersion.
Strong Answer:
  • 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.
Follow-up: When does the CLT fail or give misleading results, even with a large sample?The CLT fails when the underlying distribution does not have a finite variance. The canonical example is a Cauchy distribution (heavy-tailed), where the sample mean does not converge to anything normal no matter how many samples you take. In practice, this matters for financial data — stock returns have heavier tails than normal, and models that assume normal distributions (like VaR) systematically underestimate tail risk. The 2008 financial crisis was partly caused by this exact mistake. Another practical failure mode is when your data has structural dependencies that violate the “independent and identically distributed” assumption — like time-series data with autocorrelation or clustered data where observations within a cluster are correlated. In those cases, the effective sample size is much smaller than the nominal sample size, and the CLT-based confidence intervals are too narrow.
Strong Answer:
  • 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.
Follow-up: What is the difference between using a binomial exact test versus a normal approximation here, and when does it matter?For n=500 and p=0.02, the normal approximation is adequate because np=10 and n(1-p)=490 are both greater than 5. The binomial exact test would give P(X >= 18 given n=500, p=0.02) directly without the normal approximation. The two answers will be close — typically within 0.1% of each other at this sample size. The exact test matters when either np or n(1-p) is small, which happens with very rare events (like a 0.01% defect rate tested on 100 items). In those cases, the normal approximation can be meaningfully wrong, and you should use the exact binomial or a Poisson approximation instead. In modern practice, there is little reason not to use the exact test since computational cost is negligible, but understanding when the approximation breaks helps you catch errors in older tools that default to normal.