Foundations to Frontier
Tests
A. Mathematical Foundations › A4 Probability Theory › Basics

PMF, PDF and CDF

Three ways to describe a distribution. The PMF gives probabilities at points, the PDF gives probability per unit length, and the CDF gives cumulative probability up to x. The CDF works for every random variable, including mixed ones. Densities transform with a Jacobian factor, quantiles invert the CDF, and inverse-transform and rejection sampling turn uniform random numbers into any distribution you need.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Bars, curves and running totals

For a die, draw a bar of height 1/6 over each face. That bar chart is the PMF. For a smoothly varying quantity like a waiting time, draw a curve instead, where the area under it between two values is the probability. That’s the PDF.

There’s a third view that works for everything: the running total “probability of being at most x”, called the CDF. For the die, it climbs in steps of 1/6. For a waiting time, it rises smoothly from 0 to 1.

PMF / PDF and the CDF: two views of one distribution
PDF f(x)CDF F(x) = P(X ≤ x)
P(a < X ≤ b) = F(b) − F(a) = 0.9046 − 0.5323 = 0.3723 · quantile F⁻¹(0.50) = 0.694
Orange: the probability of (a, b], as bars or area above and as the jump in F below. Dashed purple: the quantile (go across at height u, then down). Discrete CDFs are staircases, continuous ones are smooth, and the mixed one rises smoothly and then jumps at the atom.
Why engineers care

“What’s the probability a battery lasts more than 1000 hours?” is read straight off the CDF. Simulators turn plain random numbers into realistic sensor noise or failure times by inverting the CDF. Every physics engine and reliability analysis does this millions of times.

📝 Quick check (Level 0)
0/3 answered
  1. 1. For a die, P(X ≤ 3) = ?
  2. 2. For a smooth distribution, probability between a and b is the…
  3. 3. A CDF always ends at…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

Definitions

  • PMF (discrete): p(x)=P(X=x)p(x) = P(X = x), with ∑p=1\sum p = 1.
  • PDF (continuous): f≥0f\ge0 with P(a≤X≤b)=∫abfP(a\le X\le b) = \int_a^bf and ∫f=1\int f = 1.
  • CDF (all random variables): F(x)=P(X≤x)F(x) = P(X\le x).
Relation Discrete Continuous
from the PMF/PDF to FF F(x)=∑t≤xp(t)F(x) = \sum_{t\le x}p(t) F(x)=∫−∞xfF(x) = \int_{-\infty}^xf
from FF back jump size F(x)−F(x−)F(x) - F(x^-) f=F′f = F'
interval P(a<X≤b)=F(b)−F(a)P(a < X\le b) = F(b) - F(a) same

Properties of every CDF:

  • non-decreasing;
  • right-continuous;
  • F(−∞)=0F(-\infty) = 0 and F(∞)=1F(\infty) = 1.

Examples:

  • Exp(λ)\text{Exp}(\lambda): F(x)=1−e−λxF(x) = 1 - e^{-\lambda x} and f=λe−λxf = \lambda e^{-\lambda x}.
  • Uniform(0,1)\text{Uniform}(0,1): F(x)=xF(x) = x on [0,1][0,1].
📝 Quick check (Level 1)
0/3 answered
  1. 1. Exp(1): F(1) = ?
  2. 2. Uniform(0,1): P(0.2 < X ≤ 0.5) = ?
  3. 3. The density is the ___ of the CDF.

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Quantiles

The quantile function is F−1(u)=min⁡{x:F(x)≥u}F^{-1}(u) = \min\{x: F(x)\ge u\} (the generalized inverse). It works even when FF jumps or is flat.

  • The median is F−1(0.5)F^{-1}(0.5). For Exp(1)\text{Exp}(1), it’s ln⁡2≈0.693\ln2\approx0.693.
  • Tail percentiles (the 95th, the 99.9th) set safety margins and real-time deadlines, where means are useless.

Change of variables

If Y=g(X)Y = g(X) with gg monotone and differentiable, then

fY(y)=fX(g−1(y)) ∣ddyg−1(y)∣f_Y(y) = f_X\big(g^{-1}(y)\big)\,\Big|\frac{d}{dy}g^{-1}(y)\Big|

The factor rescales lengths. For example, Y=eXY = e^X with X∼N(0,1)X\sim\mathcal N(0,1) is log-normal, with fY(y)=φ(ln⁡y)yf_Y(y) = \frac{\varphi(\ln y)}{y}. For non-monotone gg, sum over branches, or go through the CDF.

Sampling from any distribution

  • Inverse transform: if U∼Uniform(0,1)U\sim\text{Uniform}(0,1), then F−1(U)F^{-1}(U) has CDF FF. For an exponential, −ln⁡(1−U)/λ-\ln(1-U)/\lambda.
  • Rejection sampling: if f≤Mgf\le Mg, propose x∼gx\sim g and accept with probability f(x)/(Mg(x))f(x)/(Mg(x)). The acceptance rate is 1/M1/M.
🐍 Exercise 1: CDFs, densities and change of variables
Use the exponential CDF for interval probabilities and recover the density by differentiating. Check that a die's CDF is a right-continuous staircase. Derive the log-normal density by change of variables and match it to simulation.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The median of Exp(1) is…
  2. 2. Inverse-transform sampling of Exp(λ) uses…
  3. 3. Rejection sampling accepts a fraction…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Proofs

  • Interval rule. {X≤b}={X≤a}⊔{a<X≤b}\{X\le b\} = \{X\le a\}\sqcup\{a < X\le b\}, so F(b)=F(a)+P(a<X≤b)F(b) = F(a) + P(a < X\le b). ∎
  • CDF properties. Monotone because {X≤a}⊆{X≤b}\{X\le a\}\subseteq\{X\le b\}. Right-continuity and the limits follow from continuity of probability (A4.1-1) along decreasing or increasing events. ∎
  • Change of variables (increasing gg). FY(y)=P(g(X)≤y)=P(X≤g−1(y))=FX(g−1(y))F_Y(y) = P(g(X)\le y) = P(X\le g^{-1}(y)) = F_X(g^{-1}(y)). Differentiating with the chain rule gives fX(g−1(y)) (g−1)′(y)f_X(g^{-1}(y))\,(g^{-1})'(y). For decreasing gg, the sign flips, hence the absolute value. In several dimensions the factor becomes ∣det⁡J∣|\det J| (A3.2-5, A3.2-8). ∎
  • Inverse transform. For continuous strictly increasing FF, P(F−1(U)≤x)=P(U≤F(x))=F(x)P(F^{-1}(U)\le x) = P(U\le F(x)) = F(x). With the generalized inverse it holds for every FF. ∎

The probability integral transform

Conversely, if XX has a continuous CDF FF, then F(X)∼Uniform(0,1)F(X)\sim\text{Uniform}(0,1). This is the basis of goodness-of-fit tests (Kolmogorov–Smirnov), of calibration checks (are predicted CDF values uniform?), and of copulas, which separate a joint distribution’s marginals from its dependence.

Exercise 3.1: Find the density of Y = X² for X ~ Uniform(0, 1)

FY(y)=P(X≤y)=yF_Y(y) = P(X\le\sqrt y) = \sqrt y, so fY(y)=12yf_Y(y) = \frac1{2\sqrt y} on (0,1](0,1]. That’s unbounded near 0, yet it integrates to 1.

📝 Quick check (Level 3)
0/3 answered
  1. 1. If X has a continuous CDF F, F(X) is…
  2. 2. The density of X² for X ~ U(0,1)?
  3. 3. In n dimensions, the change-of-variables factor is…

Level 4: Expert

★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.

Simulation engines: sampling and checking

Monte Carlo reliability and mission-risk studies sample component lifetimes from fitted distributions. They often use Weibull, F(t)=1−e−(t/λ)kF(t) = 1 - e^{-(t/\lambda)^k}, with inverse λ(−ln⁡(1−u))1/k\lambda(-\ln(1-u))^{1/k}. Shape k<1k < 1 models infant mortality, k=1k = 1 random failures, and k>1k > 1 wear-out (the bathtub curve). Heavy-tailed noise such as Cauchy or Student-t is sampled the same way to stress-test estimators. Every sampler should be checked with a Kolmogorov–Smirnov distance sup⁡∣Fn−F∣\sup|F_n - F| against its target (A3.5-2’s DKW bound).

🐍 Exercise 2 (research): build and verify samplers
Implement inverse-transform samplers for the exponential, Weibull (reliability) and Cauchy (heavy tail) distributions, and a rejection sampler for Beta(3, 2). Verify each with a Kolmogorov–Smirnov distance, and confirm the rejection acceptance rate is 1/M.

CDFs in AI and robotics

  • Normalizing flows chain invertible maps and track densities with the change-of-variables formula. Inverse autoregressive and spline flows are built from 1-D monotone CDF-like transforms (Rezende and Mohamed, 2015; Durkan et al., 2019).
  • Calibration and conformal prediction. Probabilistic forecasts are calibrated when PIT values F(y)F(y) are uniform (Gneiting, Balabdaoui and Raftery, 2007). Conformal prediction uses empirical quantiles of residuals to give distribution-free prediction intervals (Angelopoulos and Bates, 2023), for example for safe robot planning.
  • Risk-sensitive control and RL. Distributional RL learns the return’s quantile function (Dabney et al., 2018). Value-at-risk and CVaR are quantile-based objectives for safe planning (Majumdar and Pavone, 2020).
  • Real-time systems. Control-loop deadlines use high latency percentiles from the empirical CDF (Practice Code 5).

References

  1. D. Bertsekas, J. Tsitsiklis (2008). Introduction to Probability, 2nd ed., Ch. 3–4. Athena Scientific.
  2. L. Devroye (1986). Non-Uniform Random Variate Generation. Springer.
  3. W. Weibull (1951). “A statistical distribution function of wide applicability.” Journal of Applied Mechanics, 18.
  4. D. Rezende, S. Mohamed (2015). “Variational inference with normalizing flows.” ICML.
  5. C. Durkan, A. Bekasov, I. Murray, G. Papamakarios (2019). “Neural spline flows.” NeurIPS.
  6. T. Gneiting, F. Balabdaoui, A. Raftery (2007). “Probabilistic forecasts, calibration and sharpness.” JRSS B, 69(2).
  7. A. Angelopoulos, S. Bates (2023). “Conformal prediction: a gentle introduction.” Foundations and Trends in ML, 16(4).
  8. W. Dabney, M. Rowland, M. Bellemare, R. Munos (2018). “Distributional reinforcement learning with quantile regression.” AAAI.
  9. A. Majumdar, M. Pavone (2020). “How should a robot assess risk? Towards an axiomatic theory of risk in robotics.” Robotics Research (ISRR 2017), Springer.