Probability and Distributions
A classifier doesn't output "the answer" — it outputs a belief, expressed as a probability distribution over possible answers. Every loss function in this knowledge base is a statement about how that belief compares to reality. This page is the probability vocabulary everything downstream assumes you already have.
A classifier's output is a conditional distribution , and every loss here is a statement about that distribution.

Sample space, events, random variables
The sample space is the set of all possible outcomes (e.g., all six faces of a die). An event is a subset of (e.g., "rolled an even number"). A random variable is a function mapping outcomes to numbers, letting you talk about "the value" rather than "the outcome."
Discrete vs. continuous: PMF, PDF, CDF
- PMF (probability mass function), discrete : , and .
- PDF (probability density function), continuous : where . Note is not a probability itself — only the integral over a range is.
- CDF (cumulative distribution function): , applies to both.
Expectation and variance
| Symbol | Meaning |
|---|---|
| expectation — the long-run average value of | |
| variance — expected squared deviation from the mean |
Joint, marginal, conditional
- Joint: , the probability of both and .
- Marginal: — summing out the variable you don't care about.
- Conditional: — the distribution of once is known.
Independence
and are independent iff for all — equivalently, knowing tells you nothing about . This assumption is the backbone of Naive Bayes, and it's usually false — which is exactly why that page is interesting.
Bayes' rule
Worked example (the base-rate trap): a disease affects 1% of the population; a test is 99% accurate (both sensitivity and specificity). Given a positive test, what's the probability of actually having the disease?
Only 50%, not 99% — because the disease is rare, false positives from the healthy 99% of the population outnumber true positives from the sick 1%. Ignoring the base rate is the single most common probability mistake in applied ML.
The distributions that matter
| Distribution | Support | Use |
|---|---|---|
| Bernoulli | a single binary outcome (coin flip, binary label) | |
| Categorical | a single outcome among classes | |
| Gaussian (Normal) | continuous data, noise, weight initialisation | |
| Uniform | "no prior preference" over a range | |
| Exponential | waiting times, time-to-event |
The Gaussian's special status
The Gaussian has PDF . It arises constantly because of the central limit theorem: the sum (or mean) of many independent random variables tends toward a Gaussian, regardless of their original distribution — which is why noise, measurement error, and aggregated effects are so often modelled as Gaussian.
Code: sampling, plotting, and an empirical CLT demo
import numpy as np
import matplotlib.pyplot as plt
rng = np.random.default_rng(0)
# --- Sample from each named distribution ---
bernoulli = rng.binomial(1, p=0.3, size=1000)
categorical = rng.choice([0, 1, 2], p=[0.5, 0.3, 0.2], size=1000)
gaussian = rng.normal(loc=0, scale=1, size=1000)
uniform = rng.uniform(low=-1, high=1, size=1000)
exponential = rng.exponential(scale=1.0, size=1000)
print("bernoulli mean:", bernoulli.mean())
print("gaussian mean/std:", gaussian.mean(), gaussian.std())
# --- Empirical central limit theorem ---
n_samples, n_sums = 10000, 30
uniform_sums = rng.uniform(0, 1, size=(n_samples, n_sums)).sum(axis=1)
fig, axes = plt.subplots(1, 2, figsize=(10, 4))
axes[0].hist(rng.uniform(0, 1, n_samples), bins=50)
axes[0].set_title("single uniform draw")
axes[1].hist(uniform_sums, bins=50)
axes[1].set_title(f"sum of {n_sums} uniform draws (bell-shaped)")
plt.savefig("clt_demo.png")
Summing 30 uniform draws already looks visibly bell-shaped despite the uniform distribution having no bell shape at all — the CLT in action.
See also
- Statistics and Estimation — using these distributions to estimate parameters from data.
- Information Theory — measuring surprise and divergence between distributions.