Key ideas
Rules. Probabilities are non-negative, the sample space has probability 1, and disjoint events add; hence and 1. For any two events . If only and are known, the Fréchet bounds give the range of the joint events4 (see Formulas).
Conditioning. . The chain rule needs no independence assumption. Marginalise with — the law of total probability: average the conditional probabilities over the cases1. From a two-way table, . Bayes' theorem turns into ; for a rare condition, even an accurate test gives a modest posterior because most positives are false positives (base-rate effect)1.
Independence. iff . Mutually exclusive events with positive probabilities are dependent (knowing one happened rules out the other). Conditional independence neither implies nor follows from independence1. Independent trials have no memory: after three even rolls, the next is still even with probability 1/2. Continuous are independent exactly when the joint density factorises, ; then their covariance is 0. For a point drawn uniformly from a region, a probability is a ratio of areas (favourable area / total area).
Random variables. A pmf gives probabilities; a density is not a probability and can exceed 1 (Uniform(0, 0.5) has density 2) — only its integral over an interval is2. The CDF rises from 0 to 12.
Expectation and variance1,2: is linear, , always. , , and for independent : — variances add, standard deviations do not. ; correlation is covariance divided by both SDs and lies in . Independence ⇒ zero covariance, but not conversely ( with uniform on )2. For a random vector with covariance , .
Distributions3:
| Distribution | Use | Mean | Variance |
|---|---|---|---|
| Bernoulli() | one yes/no trial | ||
| Binomial() | successes in fixed, independent, same- trials | ||
| Poisson() | counts of rare events (binomial limit) | ||
| Uniform() | flat density | ||
| Normal() | sums/averages (CLT) | ||
| Exponential() | waiting times, memoryless6 | ||
| Geometric() | trial of the first success, 7 | ||
| Hypergeometric() | successes in draws without replacement8 | smaller than binomial |
Counting. ways to choose of . Binomial: 3; get "at least " by summing or via the complement. Hypergeometric: 8. A count is binomial only if the trials are independent with one fixed — defects that come in batches, for example, are not. A Poisson() count with integer is a sum of independent Poisson(1) counts, so the CLT makes it nearly normal for large .
Limits. The law of large numbers: sample averages converge to the expectation. The central limit theorem: the standardised sum (or mean) of many i.i.d. variables with finite variance is approximately normal, whatever their distribution3. The mean of draws has standard deviation , so estimation error shrinks like 1. Epistemic uncertainty (about a parameter, e.g. a bent coin's bias) shrinks with data; aleatoric uncertainty (the next toss) does not1.
Sampling. Inverse transform: draw and return ; for the exponential, 5.
Formulas
Chebyshev: for any distribution with finite variance2.
Worked example
Prevalence 1%, sensitivity , false-positive rate . , so — only 16%. A second positive test that is conditionally independent given the disease status raises it to .
In code
import numpy as np
rng = np.random.default_rng(0)
lam = 2.0
u = rng.uniform(size=100_000)
x = -np.log(1 - u) / lam # inverse-CDF sample of Exponential(2)
print(round(x.mean(), 3), round(x.var(), 3)) # 0.499 0.25 (theory: 0.5, 0.25)
Common pitfalls
- Disjoint ≠ independent: with positive , means dependent.
- : forgetting the prior (base rate) is the classic Bayes error1.
- A density value is not a probability; is allowed2.
- SDs of independent sums don't add: four independent items with SD 10 have a total SD of , not 402.
- Zero correlation does not mean independence2.
- The 68–95 rule is for normal distributions; for an arbitrary distribution only Chebyshev holds (at most beyond SDs).
- Gambler's fallacy: past independent outcomes don't change the next one; long runs (10 heads) are unlikely but possible.
References
- Dive into Deep Learning — Sec. 2.6.1 A Simple Example — Tossing Coins; 2.6.2 A More Formal Treatment; 2.6.4 Multiple Random Variables; 2.6.5 An Example; 2.6.6 Expectations; 2.6.7 Discussion
- Dive into Deep Learning — Sec. 22.6.1.2 Probability Density Functions; 22.6.1.3 Cumulative Distribution Functions; 22.6.1.4–22.6.1.6 Means, Variances, Standard Deviations; 22.6.1.10 Covariance; 22.6.1.11 Correlation
- Dive into Deep Learning — Sec. 22.8.1 Bernoulli; 22.8.3 Continuous Uniform; 22.8.4 Binomial; 22.8.5 Poisson; 22.8.6 Gaussian
- Wikipedia: Fréchet inequalities — Introduction (bounds for a conjunction and a disjunction of two events)
- Wikipedia: Inverse transform sampling — The method; Examples (exponential distribution)
- Wikipedia: Exponential distribution — Infobox (mean, variance); Properties (Memorylessness)
- Wikipedia: Geometric distribution — Infobox and Definition (pmf, mean, variance); Properties (Memorylessness)
- Wikipedia: Hypergeometric distribution — Infobox; Definitions (sampling without replacement)