1.3.7Probability & Statistics

Cumulative distribution functions

2,473 words11 min readdifficulty · medium2 backlinks

What is a Cumulative Distribution Function?

Key properties that every CDF must satisfy:

  1. Monotonically non-decreasing: If x1<x2x_1 < x_2, then FX(x1)FX(x2)F_X(x_1) \leq F_X(x_2)
  2. Limits: limxFX(x)=0\lim_{x \to -\infty} F_X(x) = 0 and limxFX(x)=1\lim_{x \to \infty} F_X(x) = 1
  3. Right-continuous: limh0+FX(x+h)=FX(x)\lim_{h \to 0^+} F_X(x+h) = F_X(x)

Deriving the CDF from First Principles

For Discrete Random Variables

Start with the PMF: Suppose we have a discrete random variable XX with probability mass function pX(x)=P(X=x)p_X(x) = P(X = x).

Step 1 — What does P(Xx)P(X \leq x) mean?
We want the total probability of all outcomes up to and including xx. Since probabilities of disjoint events add:

FX(x)=P(Xx)=xixpX(xi)F_X(x) = P(X \leq x) = \sum_{x_i \leq x} p_X(x_i)

Why this step? We're accumulating individual point probabilities. Each value xix_i that's x\leq x contributes its probability mass.

For Continuous Random Variables

Start with the PDF: For continuous XX with probability density function fX(x)f_X(x), probabilities are areas under the curve.

Step 1 — Probability as an integral:
Since P(a<Xb)=abfX(x)dxP(a < X \leq b) = \int_a^b f_X(x)\,dx, the cumulative probability from -\infty to xx is:

FX(x)=P(Xx)=xfX(t)dtF_X(x) = P(X \leq x) = \int_{-\infty}^{x} f_X(t)\,dt

Why this step? We're integrating (accumulating) all the infinitesimal probability "slices" fX(t)dtf_X(t)\,dt from the far left up to point xx.

Step 2 — Recovering the PDF from the CDF:
By the Fundamental Theorem of Calculus:

fX(x)=ddxFX(x)f_X(x) = \frac{d}{dx} F_X(x)

Why this relationship? The PDF is the rate of change of cumulative probability. The CDF is the antiderivative.

Figure — Cumulative distribution functions

Computing Probabilities with the CDF


Connection to Quantiles and Percentiles

Why do we care in ML?

  • Confidence intervals: "95% of predictions fall below this threshold"
  • Random sampling: Generate samples via X=F1(U)X = F^{-1}(U) where UUniform(0,1)U \sim \text{Uniform}(0,1)
  • Outlier detection: Flag data points beyond the 99th percentile

Properties and Relationships


Applications in Machine Learning

  1. Model Evaluation:

    • Computing prediction intervals: P(ypred[a,b])P(y_{\text{pred}} \in [a, b])
    • Calibration curves compare predicted CDF to empirical CDF
  2. Data Preprocessing:

    • Quantile normalization: map data to uniform distribution via CDF
    • Outlier detection: flag points where FX(x)>0.99F_X(x) > 0.99 or <0.01< 0.01
  3. Generative Models:

    • Inverse transform sampling: Generate samples from any distribution using uniform random numbers
    • Copulas: Model joint distributions by combining marginal CDFs
  4. Statistical Tests:

    • Kolmogorov-Smirnov test compares empirical CDF to theoretical CDF
    • p-values are tail probabilities: p=1Fnull(tobs)p =1 - F_{\text{null}}(t_{\text{obs}})

Recall Explain to a 12-Year-Old

Imagine you're collecting Pokémon cards, and you track how rare each card is.

The probability density is like a bar chart showing how common each card level is. A CDF is different — it answers: "If I pick a random card, what's the chance it's this rare or less?"

Picture walking through the cards from least rare to most rare, and keeping running count of "How many have I seen so far?" That running percentage is the CDF.

When you reach the end (the rarest card), your CDF hits 100% because you've counted all the cards.

Why is this useful? If someone asks "What's the chance I pull a card that's in the bottom 75%?", you just look at the CDF at the 75% mark. No complicated addition needed!



Connections

  • Probability Distributions — CDF is the integral of the PDF
  • Random Variables — CDF is defined for any random variable
  • Expected Value and Variance — Can compute E[X]E[X] using CDF
  • Inverse Transform Sampling — Uses F1F^{-1} to generate random samples
  • Quantile Functions — The inverse of the CDF
  • Empirical Distribution — Sample-based estimate of the CDF
  • Kolmogorov-Smirnov Test — Compares CDFs for goodness-of-fit
  • Copulas — Join marginal CDFs to model dependence
  • Survival Analysis — Uses survival function S(x)=1FX(x)S(x) = 1 - F_X(x)

#flashcards/ai-ml

What does the CDF FX(x)F_X(x) represent? :: The probability that random variable XX is less than or equal to xx: FX(x)=P(Xx)F_X(x) = P(X \leq x)

What are the range and domain of a CDF?
Domain: all real numbers R\mathbb{R}. Range: [0,1][0, 1] (probabilities).
True or False: A CDF can decrease as xx increases.
False. CDFs are monotonically non-decreasing.
How do you compute P(a<Xb)P(a < X \leq b) using the CDF?
P(a<Xb)=FX(b)FX(a)P(a < X \leq b) = F_X(b) - F_X(a)
For a continuous random variable, what is the relationship between PDF and CDF?
FX(x)=xfX(t)dtF_X(x) = \int_{-\infty}^{x} f_X(t)\,dt and fX(x)=ddxFX(x)f_X(x) = \frac{d}{dx} F_X(x)
For a discrete random variable, how is the CDF computed from the PMF?
FX(x)=xixpX(xi)F_X(x) = \sum_{x_i \leq x} p_X(x_i) (sum all probabilities of outcomes x\leq x)
What is the quantile function?
The inverse CDF FX1(p)F_X^{-1}(p), which gives the value xx such that FX(x)=pF_X(x) = p.
What is FX1(0.5)F_X^{-1}(0.5) called?
The median of the distribution.
What is P(X=x)P(X = x) for a continuous random variable?
Zero. For continuous variables, P(X=x)=0P(X = x) = 0.
How do you compute P(X>x)P(X > x) using the CDF?
P(X>x)=1FX(x)P(X > x) = 1 - F_X(x)
What are the limit properties of a CDF?
limxFX(x)=0\lim_{x \to -\infty} F_X(x) = 0 and limxFX(x)=1\lim_{x \to \infty} F_X(x) = 1
For XUniform(0,1)X \sim \text{Uniform}(0,1), what is FX(0.3)F_X(0.3)?
FX(0.3)=0.3F_X(0.3) = 0.3 (the CDF is FX(x)=xF_X(x) = x for x[0,1]x \in [0,1])
What shape does a discrete CDF have?
A staircase (step function) with jumps at each possible value.
How is inverse transform sampling performed?
Generate UUniform(0,1)U \sim \text{Uniform}(0,1), then compute X=FX1(U)X = F_X^{-1}(U).
What does the95th percentile mean?
The value xx such that 95% of the distribution is x\leq x, i.e., FX(x)=0.95F_X(x) = 0.95.

Concept Map

sum up to x

integrate to x

defined as

domain

range

must be

limits

property

discrete shape

enables

used for

applies to

applies to

PMF discrete

CDF F_X x

PDF continuous

P X leq x

all real numbers

0 to 1

Monotonic non-decreasing

0 at neg-inf, 1 at inf

Right-continuous

Staircase function

Percentiles and thresholds

Random sampling

ML probabilistic models

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, CDF ka core idea bahut simple hai — ye ek "running total" hai probability ka. Socho tum shooting range pe ho aur poochte ho ki "kitne percent bullets 50 meters ke andar giri?" Toh yahan tum ek specific point tak ki saari probability jod rahe ho. Formally, FX(x)=P(Xx)F_X(x) = P(X \leq x), matlab random variable xx ya usse chhoti value lene ka chance kitna hai. Left se right ko sweep karte jao aur probability accumulate hoti jati hai — isliye ye hamesha 0 se start hoke 1 par khatam hoti hai, aur beech mein kabhi ghatti nahi (monotonically non-decreasing).

Ab discrete aur continuous case ka fark samajh lo. Discrete case mein — jaise dice roll — tum bas alag-alag point probabilities ko jodte ho, isliye CDF ek "staircase" jaisi dikhti hai, har value pe ek step jump. Continuous case mein — jaise Uniform distribution — probability area hoti hai curve ke neeche, toh tum integrate karte ho PDF ko -\infty se lekar xx tak. Aur ek khoobsurat baat: agar tum CDF ka derivative lo, toh wapas PDF mil jati hai (Fundamental Theorem of Calculus). Matlab PDF cumulative probability ki rate of change hai, aur CDF uska antiderivative — dono ek dusre se connected hain.

Ye cheez ML mein kyun important hai? Kyunki CDF se tum percentiles nikaal sakte ho — jaise "95% predictions is threshold ke neeche aati hain", ya confidence intervals banate ho. Random sampling generate karne mein bhi CDF ka inverse use hota hai (inverse transform sampling), aur probabilistic models samajhne ka backbone yahi hai. Toh jab bhi tumhe distribution ke baare mein "kitna tak" wale sawaal aaye, CDF hi tumhara tool hai. Isko achhe se pakad lo — aage har jagah kaam aayega.

Go deeper — visual, from zero

Test yourself — Probability & Statistics

Connections