Skip to main content
Albero Academy

Probability & Distributions

Probability basics, the Normal / Binomial / Poisson distributions, the CLT, and computing probabilities in Python.

Chapter 2Statistics16 min readBeginner friendly
  • #Statistics
  • #Probability
  • #Distributions

Probability is the language of uncertainty. Every A/B test, every confidence interval, every machine-learning model is grounded in it. This chapter covers the three distributions you'll meet most often, plus the theorem that ties everything together.

What is probability?

The chance of an event, between 0 (impossible) and 1 (certain). Two intuitions:

  • Frequentist: the long-run proportion of times the event happens.
  • Bayesian: a degree of belief that updates as evidence arrives.

Probability rules

RuleFormula
ComplementP(not A) = 1 − P(A)
Union (any)P(A or B) = P(A) + P(B) − P(A and B)
Independent intersectionP(A and B) = P(A) · P(B)
ConditionalP(A | B) = P(A and B) / P(B)
BayesP(A | B) = P(B | A) · P(A) / P(B)

The Normal distribution

The bell curve. Defined by its mean (μ) and standard deviation (σ). Many natural measurements (heights, blood pressure, IQ scores, measurement errors) follow it.

Python
from scipy.stats import norm
# Probability of being below 175cm in a population with μ=170, σ=8
print(norm.cdf(175, loc=170, scale=8)) # 0.7340
# Probability of being between 165 and 180
print(norm.cdf(180, 170, 8) - norm.cdf(165, 170, 8)) # 0.6883
# Inverse — the value below which 95% of the population falls
print(norm.ppf(0.95, loc=170, scale=8)) # 183.16

The Binomial distribution

The number of successes in n independent Yes/No trials, each with the same success probability p. Coin flips, click-or-not, defect-or-not.

Python
from scipy.stats import binom
# An ad has a 5% click-through rate. Out of 1000 impressions, what's the
# probability of getting exactly 60 clicks?
print(binom.pmf(60, n=1000, p=0.05)) # 0.0151
# Probability of 60 or more clicks
print(1 - binom.cdf(59, n=1000, p=0.05)) # 0.0813
# Mean & variance (without simulating)
print(binom.mean(1000, 0.05)) # 50
print(binom.var(1000, 0.05)) # 47.5

The Poisson distribution

The number of events in a fixed interval, given an average rate (λ). Calls to a help-desk per minute, customers entering a shop per hour, typos per page.

Python
from scipy.stats import poisson
# Customer-care line averages 4 calls per minute. What's the probability
# of getting exactly 6 calls in the next minute?
print(poisson.pmf(6, mu=4)) # 0.1042
# Probability of 0 calls in the next minute
print(poisson.pmf(0, mu=4)) # 0.0183
# Probability of 10 or more calls — overload threshold
print(1 - poisson.cdf(9, mu=4)) # 0.0081

The Central Limit Theorem

Take any distribution. Sample n values from it, take their mean, repeat. As n grows, the distribution of those sample means approaches a Normal distribution — regardless of what the underlying distribution looks like.

Python
import numpy as np
import matplotlib.pyplot as plt
# An ugly, non-normal underlying distribution
population = np.random.exponential(scale=2, size=100_000)
# Take 5000 samples of size n=30 and average each
sample_means = [np.mean(np.random.choice(population, 30)) for _ in range(5000)]
# The sample-means distribution is shockingly normal
plt.hist(sample_means, bins=50)
plt.title("CLT in action: sample means of an exponential distribution")
plt.show()

The CLT is what makes inference possible — it's why we can compute confidence intervals and run t-tests on real-world data that's almost never perfectly normal.

Key takeaways

  1. 01Probability is bounded between 0 and 1; the rules cover complement, union, intersection, conditional.
  2. 02Normal distribution: bell-shaped, defined by μ and σ. The 68/95/99.7 rule is essential.
  3. 03Binomial: yes/no trials with fixed n and p. Use it for click-through rates and defect counts.
  4. 04Poisson: events per fixed interval. Use it for call volumes, arrivals, queue length.
  5. 05The Central Limit Theorem says sample means tend toward Normal — that's why inference works on non-normal data.