1.3.6Probability & Statistics

Probability mass and density functions

3,046 words14 min readdifficulty · medium3 backlinks

Probability Mass Function (PMF)

Derivation from First Principles

START: What is a random variable? A function that maps outcomes to numbers.

STEP 1: For discrete outcomes ω1,ω2,\omega_1, \omega_2, \ldots in sample space Ω\Omega, each has probability P(ωi)P(\omega_i).

STEP 2: Random variable XX maps ωixi\omega_i \to x_i. Multiple outcomes can map to the same xx.

STEP 3: The probability that XX takes value xx is the sum of probabilities of all outcomes that map to xx: pX(x)=P(X=x)=ω:X(ω)=xP(ω)p_X(x) = P(X = x) = \sum_{\omega: X(\omega) = x} P(\omega)

WHY this form? By the axiom of countable additivity: if events are disjoint (different outcomes), their probabilities add.

Property 1 proof: Since 0P(ω)10 \leq P(\omega) \leq 1 for each outcome, and we're summing non-negative terms, 0pX(x)10 \leq p_X(x) \leq 1.

Property 2 proof: xpX(x)=xω:X(ω)=xP(ω)=ωΩP(ω)=1\sum_x p_X(x) = \sum_x \sum_{\omega: X(\omega)=x} P(\omega) = \sum_{\omega \in \Omega} P(\omega) = 1 We're just regrouping the same outcome probabilities.

Figure — Probability mass and density functions

Probability Density Function (PDF)

Why Points Have Zero Probability

The intuition: Imagine measuring someone's height. What's the probability their height is EXACTLY 170.000... cm (infinite precision)? Zero. But the probability their height is between 169.5 and 170.5 cm? Non-zero.

Mathematical reason: P(X=c)=ccfX(x)dx=0P(X = c) = \int_c^c f_X(x) \, dx = 0 An integral from cc to cc has zero width.

Consequence: For continuous variables, P(aXb)=P(a<X<b)P(a \leq X \leq b) = P(a < X < b)—boundary points don't matter.

Derivation from Discrete to Continuous

START: Consider a discrete variable with outcomes at xi=iΔxx_i = i\Delta x for small Δx\Delta x.

STEP 1: PMF gives pX(xi)=P(X=xi)p_X(xi) = P(X = x_i).

STEP 2: As Δx0\Delta x \to 0, we pack more and more outcomes into any interval [a,b][a,b].

STEP 3: The probability of interval [x,x+Δx][x, x+\Delta x] approaches pX(x)fX(x)Δxp_X(x) \approx f_X(x) \cdot \Delta x.

WHY? Think of fX(x)f_X(x) as "probability per unit length." Multiply by length Δx\Delta x to get probability.

STEP 4: Sum over the interval [a,b][a,b]: P(aXb)=limΔx0xi[a,b]fX(xi)Δx=abfX(x)dxP(a \leq X \leq b) = \lim_{\Delta x \to 0} \sum_{x_i \in [a,b]} f_X(x_i) \Delta x = \int_a^b f_X(x) \, dx

This is the Riemann integral definition.

PMF vs PDF: The Critical Differences

| Property | PMF (Discrete) | PDF (Continuous) | |----------|------------------| | Values | pX(x)=P(X=x)p_X(x) = P(X=x) | fX(x)f_X(x) is NOT a probability | | Range | 0pX(x)10 \leq p_X(x) \leq 1 | fX(x)0f_X(x) \geq 0, can exceed 1! | | Total | xpX(x)=1\sum_x p_X(x) = 1 | fX(x)dx=1\int_{-\infty}^\infty f_X(x) dx = 1 | | Point prob | pX(x)p_X(x) is the answer | P(X=x)=0P(X=x) = 0 | | Interval prob | x[a,b]pX(x)\sum_{x \in [a,b]} p_X(x) | abfX(x)dx\int_a^b f_X(x) dx |

Recall Feynman Explanation (Explain to a 12-year-old)

Imagine you have a big jar of marbles, each with a number written on it. If you can COUNT the marbles (1, 2, 3, ..), that's discrete. I can tell you exactly: "The probability of picking marble #7 is 1 out of 20." That's a PMF—it gives the exact chance for each marble.

Now imagine instead the jar is full of sand, and you're measuring how much gold dust is mixed in. You can't pick out a single grain and ask its probability—there are infinite grains! But I can tell you: "In this REGION of the jar, there's a lot of gold; in that region, very little." That's what a PDF does—it tells you where the "gold" (probability) is concentrated.

If I scoop a tiny spoonful from the high-density region, I'll probably get some gold. If I scoop from the low-density region, probably not. But a single grain? Zero gold (zero probability). The density tells you: look in THIS neighborhood if you want to find gold.

In machine learning, every time your model says "I think the answer is around here," it's giving you a density function!

Connections

  • 1.3.01-Random-variables-and-distributions — PMF/PDF formalize the distribution of a random variable
  • 1.3.07-Cumulative-distribution-functions — CDF unifies discrete and continuous cases; FX=fXF_X' = f_X
  • 1.3.08-Expected-value-and-variance — Computed as E[X]=xpX(x)E[X] = \sum x \cdot p_X(x) or xfX(x)dx\int x \cdot f_X(x) dx
  • 1.3.09-Common-probability-distributions — Specific PMFs (Binomial, Poisson) and PDFs (Gaussian, Exponential)
  • 1.4.02-Maximum-likelihood-estimation — Finding parameters that maximize pX(xi)\prod p_X(x_i) or fX(xi)\prod f_X(x_i)
  • 2.1.05-Softmax-activation — Softmax converts logits to a PMF over classes
  • 3.2.04-Gaussian-processes — Model functions as draws from a distribution with PDF over function space

#flashcards/ai-ml

What is the key difference between a PMF and a PDF? :: PMF gives exact probabilities for discrete outcomes: pX(x)=P(X=x)p_X(x) = P(X=x). PDF gives probability density for continuous variables—probability is the integral (area), not the value itself: P(aXb)=abfX(x)dxP(a \leq X \leq b) = \int_a^b f_X(x) dx.

What are the two properties that any PMF must satisfy?
(1) 0pX(x)10 \leq p_X(x) \leq 1 for all xx, and (2) all xpX(x)=1\sum_{\text{all } x} p_X(x) = 1.
What are the two properties that any PDF must satisfy?
(1) fX(x)0f_X(x) \geq 0 for all xx, and (2) fX(x)dx=1\int_{-\infty}^{\infty} f_X(x) dx = 1.
Why is P(X=c)=0P(X = c) = 0 for any specific value cc of a continuous random variable?
Because the probability is the area under the PDF curve, and a single point has zero width, hence zero area: P(X=c)=ccfX(x)dx=0P(X=c) = \int_c^c f_X(x) dx = 0.
What is the relationship between PDF and CDF?
The PDF is the derivative of the CDF: fX(x)=ddxFX(x)f_X(x) = \frac{d}{dx} F_X(x). The CDF is the integral of the PDF: FX(x)=xfX(t)dtF_X(x) = \int_{-\infty}^x f_X(t) dt.
Can a PDF value fX(x)f_X(x) be greater than 1?
Yes! PDF is a density (probability per unit), not a probability. Example: uniform on [0,0.5][0, 0.5] has fX(x)=2f_X(x) = 2.
What is the PMF of a Bernoulli random variable with success probability pp?
pX(1)=pp_X(1) = p and pX(0)=1pp_X(0) = 1-p, or compactly: pX(x)=px(1p)1xp_X(x) = p^x(1-p)^{1-x} for x{0,1}x \in \{0,1\}.
What is the PDF of a uniform distribution on [a,b][a, b]?
fX(x)=1baf_X(x) = \frac{1}{b-a} for x[a,b]x \in [a,b], and 00 otherwise. The constant density ensures total probability is 1.
What is the PDF of an exponential distribution with rate λ\lambda?
fX(x)=λeλxf_X(x) = \lambda e^{-\lambda x} for x0x \geq 0, and 00 otherwise. It models waiting times in memoryless processes.
What is the PDF of a Gaussian distribution with mean μ\mu and variance σ2\sigma^2?
fX(x)=1σ2πexp((xμ)22σ2)f_X(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) for all xRx \in \mathbb{R}.
How do you compute P(aXb)P(a \leq X \leq b) for a discrete random variable?
P(aXb)=x=abpX(x)P(a \leq X \leq b) = \sum_{x=a}^{b} p_X(x) (sum the PMF over the interval).
How do you compute P(aXb)P(a \leq X \leq b) for a continuous random variable?
P(aXb)=abfX(x)dxP(a \leq X \leq b) = \int_a^b f_X(x) dx (integrate the PDF over the interval).
Why do we use PMF for classification and PDF for regression in ML?
Classification outputs discrete class labels (finite outcomes) → PMF over classes. Regression outputs continuous values (infinite possibilities) → PDF over the real line.
If two dice are rolled and XX is their sum, what is pX(7)p_X(7)?
There are 6 outcomes giving sum 7: (1,6),(2,5),(3,4),(4,3),(5,2),(6,1)(1,6),(2,5),(3,4),(4,3),(5,2),(6,1) out of 36 total equally likely outcomes. So pX(7)=6/36=1/6p_X(7) = 6/36 = 1/6.
What does "memoryless property" of the exponential distribution mean?
P(X>s+tX>s)=P(X>t)P(X > s+t \mid X > s) = P(X > t): the probability of waiting an additional tt time doesn't depend on how long you've already waited. The past doesn't matter.

Concept Map

maps outcomes to numbers

discrete

continuous

defined as

single point

describes

derived from

ensures

used in ML for

used in ML for

both quantify

both quantify

Random Variable

Discrete or Continuous

PMF p_X x

PDF f_X x

P X equals x

Probability equals 0

Relative likelihood over intervals

Countable additivity axiom

Non-negative and sums to 1

Classification over classes

Regression over values

Uncertainty

Hinglish (regional understanding)

Intuition Hinglish mein samjho

PMF aur PDF: Probability ko samajhne ka tarika

Socho tum ek AI model bana rahe ho jo predict karta hai kikal barish hogi ya nahi. Yeh ek discrete problem hai—do outcomes hain: haan ya na. Har outcome ko ek exact probability milti hai, jaise 0.7 (barish) aur 0.3 (no barish). Yeh PMF (Probability Mass Function) ka kaam hai. Yeh tumhe bolta hai ki kisi specific outcome ki exact probability kya hai. Jaise dice roll karo, toh sum = 7 ane ki probability PMF se milti hai.

Ab socho tum predict kar rahe ho ki kal temperature kya hoga—23.5°C, 23.51°C, 23.512°C... infinite possibilities hain! Yahanek single value ki probability zero hai (kyunki infinite values mein se koiek exact match ho—bahut rare!). Toh hum PDF (Probability Density Function) use karte hain. PDF tumhe bata hai ki probability ka "concentration" kahan zyada hai. Agar tum ek chhota interval lo, jaise 23°C se 24°C, toh PDF ko integrate karke (area nikalke) probability milti hai. PDF is like density of gold dust in sand—jahan density zyada, wahan probability zyada.

ML mein kyun zaroori hai? Jab bhi tumara model kuch predict karta hai—classification mein class probabilities (PMF), regression mein continuous values

Go deeper — visual, from zero

Test yourself — Probability & Statistics

Connections