Discrete Random Variables — PMF, CDF, Expectation & Variance (Layered)

2099 words
10 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Discrete Random Variables — PMF, CDF, Expectation & Variance > **Layered Deep-Dive:** This chapter reconstructs Discrete Random Variables from first principles. We map abstract sample spaces $\Omega$ onto real numbers $\mathbb{R}$, master the Probability Mass Function (PMF) and the right-continuous step nature of...

Discrete Random Variables — PMF, CDF, Expectation & Variance

Layered Deep-Dive: This chapter reconstructs Discrete Random Variables from first principles. We map abstract sample spaces Ω\Omega onto real numbers R\mathbb{R}, master the Probability Mass Function (PMF) and the right-continuous step nature of the Cumulative Distribution Function (CDF), derive interval probabilities without boundary errors, and calculate Expectation E[X]E[X] and Variance Var(X)Var(X) for Quiz 3.

1. Orientation & Intuition: From Events to Numbers

In elementary probability, we describe random experiments using descriptive sample spaces:
  • Tossing three coins yields outcomes like Ω={HHH,HHT,HTH,HTT,THH,THT,TTH,TTT}\Omega = \{HHH, HHT, HTH, HTT, THH, THT, TTH, TTT\}.
  • Describing events like "at least two heads" requires grouping text tuples: E={HHH,HHT,HTH,THH}E = \{HHH, HHT, HTH, THH\}.
While intuitive, working directly with sets of strings becomes unwieldy when modeling complex systems like stock price shifts, defect counts, or queue wait times.
We need a mathematical mechanism to translate qualitative outcomes into numerical values:
Outcome ω∈Ω→XNumber x∈R\text{Outcome } \omega \in \Omega \xrightarrow{\quad X \quad} \text{Number } x \in \mathbb{R}
This mapping function is a Random Variable (RV). For three coin tosses, let XX denote the "number of heads":
  • X(TTT)=0X(TTT) = 0
  • X(HTT)=X(THT)=X(TTH)=1X(HTT) = X(THT) = X(TTH) = 1
  • X(HHT)=X(HTH)=X(THH)=2X(HHT) = X(HTH) = X(THH) = 2
  • X(HHH)=3X(HHH) = 3
Now, instead of tracking 8 outcome strings, we can perform arithmetic, calculate averages, compute spread, and model distributions on the set of numbers {0,1,2,3}\{0, 1, 2, 3\}.

2. Terminology, Notation & Mathematical Definitions

Concept / SymbolMathematical DefinitionKey Meaning & Properties
Random Variable XXX:Ω→RX: \Omega \to \mathbb{R}A real-valued function defined over the sample space Ω\Omega.
Support SXS_X{x∈R:P(X=x)>0}\{x \in \mathbb{R} : P(X = x) > 0\}The set of all possible numerical values XX can take with non-zero probability.
Discrete RVSXS_X is countableTakes either a finite set of values or a countably infinite set {x1,x2,… }\{x_1, x_2, \dots\}.
PMF pX(x)p_X(x)P(X=x)P(X = x)Probability Mass Function: probability concentrated at exact point xx.
CDF FX(x)F_X(x)P(X≤x)=∑t≤xpX(t)P(X \le x) = \sum_{t \le x} p_X(t)Cumulative Distribution Function: accumulated probability up to xx.
Expectation E[X]E[X]∑x∈SXx⋅pX(x)\sum_{x \in S_X} x \cdot p_X(x)The probability-weighted average (mean / center of mass) of XX.
Variance Var(X)Var(X)E[(X−μ)2]=E[X2]−(E[X])2E[(X - \mu)^2] = E[X^2] - (E[X])^2The expected squared deviation from the mean; measures dispersion.
Std Deviation σX\sigma_XVar(X)\sqrt{Var(X)}Spread expressed in the original units of measurement.

3. The Probability Mass Function (PMF)

The Probability Mass Function (PMF) of a discrete random variable XX assigns a probability to each possible discrete value.

3.1 Axiomatic Requirements of a Valid PMF

Any function p(x)p(x) is a valid PMF if and only if it satisfies two conditions:
  1. Non-negativity: p(x)≥0for all x∈SXp(x) \ge 0 \quad \text{for all } x \in S_X
  2. Total Probability Normalization: ∑x∈SXp(x)=1\sum_{x \in S_X} p(x) = 1

3.2 Finding Unknown Normalization Constants

A recurring IITM exam question gives a PMF with an unknown constant cc (e.g., p(x)=cx2p(x) = c x^2 for x∈{1,2,3}x \in \{1, 2, 3\}). To find cc, enforce the normalization axiom:
∑x=13cx2=c(12+22+32)=c(1+4+9)=14c=1  ⟹  c=114\sum_{x=1}^3 c x^2 = c(1^2 + 2^2 + 3^2) = c(1 + 4 + 9) = 14c = 1 \implies c = \frac{1}{14}

4. The Cumulative Distribution Function (CDF)

The Cumulative Distribution Function (CDF), denoted by F(x)F(x), describes the cumulative probability accumulated up to and including xx:
F(x)=P(X≤x)=∑t≤xp(t)F(x) = P(X \le x) = \sum_{t \le x} p(t)

4.1 Fundamental Properties of F(x)F(x)

  1. Bounded Range: 0≤F(x)≤10 \le F(x) \le 1 for all x∈Rx \in \mathbb{R}.
  2. Asymptotic Limits: lim⁡x→−∞F(x)=0andlim⁡x→+∞F(x)=1\lim_{x \to -\infty} F(x) = 0 \quad \text{and} \quad \lim_{x \to +\infty} F(x) = 1
  3. Monotonically Non-Decreasing: If x1<x2x_1 < x_2, then F(x1)≤F(x2)F(x_1) \le F(x_2).
  4. Right-Continuous: For any point aa: lim⁡x→a+F(x)=F(a)\lim_{x \to a^+} F(x) = F(a)
  5. Step Discontinuity Theorem: For a discrete RV, F(x)F(x) is a piecewise-constant step function. The height of the jump at any value kk equals the probability mass at that value: P(X=k)=F(k)−lim⁡x→k−F(x)=F(k)−F(k−)P(X = k) = F(k) - \lim_{x \to k^-} F(x) = F(k) - F(k^-)
F(x) CDF Step Graph:
1.0 |                _________
0.7 |        _______|
0.3 |  _____|
0.0 |__|
    +---+-------+----+--------
        1       2    3        x
Jump at x=2 is: F(2) - F(2^-) = 0.7 - 0.3 = 0.4 = P(X=2)

5. Converting Between Intervals and CDF Values

Because discrete random variables place probability mass in concentrated point spikes, the presence or absence of the equality sign strictly alters the probability!
Desired ProbabilityDiscrete CDF FormulaExplanation
P(X≤b)P(X \le b)F(b)F(b)By direct definition of CDF.
P(X<b)P(X < b)F(b−)=lim⁡x→b−F(x)F(b^-) = \lim_{x \to b^-} F(x)Excludes the point mass at bb.
P(X>a)P(X > a)1−P(X≤a)=1−F(a)1 - P(X \le a) = 1 - F(a)Complement rule.
P(X≥a)P(X \ge a)1−P(X<a)=1−F(a−)1 - P(X < a) = 1 - F(a^-)Complement of strictly less than aa.
P(a<X≤b)P(a < X \le b)F(b)−F(a)F(b) - F(a)Standard cumulative interval formula.
P(a≤X≤b)P(a \le X \le b)F(b)−F(a−)=F(b)−F(a)+P(X=a)F(b) - F(a^-) = F(b) - F(a) + P(X = a)Includes both boundaries aa and bb.
P(a<X<b)P(a < X < b)F(b−)−F(a)F(b^-) - F(a)Excludes both boundaries aa and bb.
In continuous probability,
P(X<b)=P(X≤b)P(X < b) = P(X \le b) because point probabilities are zero. In discrete probability, P(X<b)≠P(X≤b)P(X < b) \neq P(X \le b)! For integer-valued RVs, P(X<5)=P(X≤4)=F(4)P(X < 5) = P(X \le 4) = F(4).

6. Expectation, Variance & Moments

6.1 Expected Value (Mean μ\mu)

The expected value is the probability-weighted average of all values XX can take:
E[X]=μ=∑x∈SXx⋅p(x)E[X] = \mu = \sum_{x \in S_X} x \cdot p(x)
Properties of Expectation:
  • Linearity: For any constants a,b∈Ra, b \in \mathbb{R}: E[aX+b]=aE[X]+bE[aX + b] = aE[X] + b
  • Expectation of a Function g(X)g(X) (LOTUS): E[g(X)]=∑x∈SXg(x)⋅p(x)E[g(X)] = \sum_{x \in S_X} g(x) \cdot p(x)

6.2 Variance and Standard Deviation

Variance measures the expected squared distance between the random variable and its mean:
Var(X)=σ2=E[(X−μ)2]=∑x∈SX(x−μ)2⋅p(x)Var(X) = \sigma^2 = E[(X - \mu)^2] = \sum_{x \in S_X} (x - \mu)^2 \cdot p(x)
Computational Shortcut Formula: Var(X)=E[X2]−(E[X])2Var(X) = E[X^2] - (E[X])^2
Where E[X2]=∑x2⋅p(x)E[X^2] = \sum x^2 \cdot p(x) is the second raw moment.
Properties of Variance:
  • Non-negativity: Var(X)≥0Var(X) \ge 0.
  • Constants have zero variance: Var(c)=0Var(c) = 0.
  • Adding a constant does not change spread: Var(X+b)=Var(X)Var(X + b) = Var(X).
  • Multiplying by a constant scales variance by the square: Var(aX+b)=a2Var(X)Var(aX + b) = a^2 Var(X)
  • Standard Deviation: σ(aX+b)=∣a∣σ(X)\sigma(aX + b) = |a| \sigma(X)

7. Worked Exam Walkthroughs

Walkthrough 1: PMF Normalization, Expectation, and Variance

Problem: A discrete random variable XX has the PMF:
p(x)={k(2x−1)for x∈{1,2,3,4}0otherwisep(x) = \begin{cases} k(2x - 1) & \text{for } x \in \{1, 2, 3, 4\} \\ 0 & \text{otherwise} \end{cases}
Find:
  1. The value of the constant kk.
  2. The expected value E[X]E[X].
  3. The variance Var(X)Var(X).
Solution:
Part 1: Find kk Evaluate p(x)p(x) for each x∈{1,2,3,4}x \in \{1, 2, 3, 4\}:
  • p(1)=k(2(1)−1)=1kp(1) = k(2(1) - 1) = 1k
  • p(2)=k(2(2)−1)=3kp(2) = k(2(2) - 1) = 3k
  • p(3)=k(2(3)−1)=5kp(3) = k(2(3) - 1) = 5k
  • p(4)=k(2(4)−1)=7kp(4) = k(2(4) - 1) = 7k
Sum of probabilities: ∑x=14p(x)=k(1+3+5+7)=16k=1  ⟹  k=116\sum_{x=1}^4 p(x) = k(1 + 3 + 5 + 7) = 16k = 1 \implies k = \frac{1}{16}
Thus, the exact probabilities are: p(1)=116,p(2)=316,p(3)=516,p(4)=716p(1) = \frac{1}{16}, \quad p(2) = \frac{3}{16}, \quad p(3) = \frac{5}{16}, \quad p(4) = \frac{7}{16}
Part 2: Find E[X]E[X] E[X]=∑x⋅p(x)=1(116)+2(316)+3(516)+4(716)E[X] = \sum x \cdot p(x) = 1\left(\frac{1}{16}\right) + 2\left(\frac{3}{16}\right) + 3\left(\frac{5}{16}\right) + 4\left(\frac{7}{16}\right) E[X]=1+6+15+2816=5016=258=3.125E[X] = \frac{1 + 6 + 15 + 28}{16} = \frac{50}{16} = \frac{25}{8} = 3.125
Part 3: Find Var(X)Var(X) First, compute E[X2]E[X^2]: E[X2]=∑x2⋅p(x)=12(116)+22(316)+32(516)+42(716)E[X^2] = \sum x^2 \cdot p(x) = 1^2\left(\frac{1}{16}\right) + 2^2\left(\frac{3}{16}\right) + 3^2\left(\frac{5}{16}\right) + 4^2\left(\frac{7}{16}\right) E[X2]=1(1)+4(3)+9(5)+16(7)16=1+12+45+11216=17016=858=10.625E[X^2] = \frac{1(1) + 4(3) + 9(5) + 16(7)}{16} = \frac{1 + 12 + 45 + 112}{16} = \frac{170}{16} = \frac{85}{8} = 10.625
Now apply the variance formula: Var(X)=E[X2]−(E[X])2=858−(258)2=858−62564Var(X) = E[X^2] - (E[X])^2 = \frac{85}{8} - \left(\frac{25}{8}\right)^2 = \frac{85}{8} - \frac{625}{64} Var(X)=680−62564=5564≈0.859Var(X) = \frac{680 - 625}{64} = \frac{55}{64} \approx 0.859
k=116,E[X]=258=3.125,Var(X)=5564≈0.859\boxed{k = \frac{1}{16}, \quad E[X] = \frac{25}{8} = 3.125, \quad Var(X) = \frac{55}{64} \approx 0.859}

Walkthrough 2: Deconstructing a Step CDF

Problem: The CDF of an integer-valued random variable XX is given by:
F(x)={0x<00.150≤x<20.552≤x<50.855≤x<81.00x≥8F(x) = \begin{cases} 0 & x < 0 \\ 0.15 & 0 \le x < 2 \\ 0.55 & 2 \le x < 5 \\ 0.85 & 5 \le x < 8 \\ 1.00 & x \ge 8 \end{cases}
Compute:
  1. P(X=2)P(X = 2)
  2. P(X>2)P(X > 2)
  3. P(2≤X<8)P(2 \le X < 8)
Solution:
  1. P(X=2)P(X = 2): By the jump discontinuity formula: P(X=2)=F(2)−F(2−)=0.55−0.15=0.40P(X = 2) = F(2) - F(2^-) = 0.55 - 0.15 = 0.40
  2. P(X>2)P(X > 2): By the complement rule: P(X>2)=1−P(X≤2)=1−F(2)=1−0.55=0.45P(X > 2) = 1 - P(X \le 2) = 1 - F(2) = 1 - 0.55 = 0.45
  3. P(2≤X<8)P(2 \le X < 8): Break down the discrete points in the range: {2,5}\{2, 5\}: P(X=2)+P(X=5)=0.40+(F(5)−F(5−))=0.40+(0.85−0.55)=0.40+0.30=0.70P(X = 2) + P(X = 5) = 0.40 + (F(5) - F(5^-)) = 0.40 + (0.85 - 0.55) = 0.40 + 0.30 = 0.70 Alternatively, using CDF limits: F(8−)−F(2−)=0.85−0.15=0.70F(8^-) - F(2^-) = 0.85 - 0.15 = 0.70
P(X=2)=0.40,P(X>2)=0.45,P(2≤X<8)=0.70\boxed{P(X = 2) = 0.40, \quad P(X > 2) = 0.45, \quad P(2 \le X < 8) = 0.70}

8. Common Traps & Pitfalls in IITM Stats 1 Exams

  1. Confusing P(X<k)P(X < k) with P(X≤k)P(X \le k): In discrete RVs taking integers, P(X<4)=P(X≤3)=F(3)P(X < 4) = P(X \le 3) = F(3), whereas P(X≤4)=F(4)P(X \le 4) = F(4). If P(X=4)>0P(X = 4) > 0, these two values are strictly different.
  2. Variance Scaling Sign Error: Remember that Var(−3X+5)=(−3)2Var(X)=9Var(X)Var(-3X + 5) = (-3)^2 Var(X) = 9 Var(X). A negative coefficient inside variance is squared and becomes positive.
  3. Subtracting Probabilities in the Wrong Order: Always remember that P(a<X≤b)=F(b)−F(a)P(a < X \le b) = F(b) - F(a). If you write F(a)−F(b)F(a) - F(b), you get a negative number, which violates probability axioms.

9. Practice Quiz Questions

Question 1 (MCQ)

If Var(X)=4Var(X) = 4, what is Var(5−2X)Var(5 - 2X)?
  • (A) −8-8
  • (B) 88
  • (C) 1616
  • (D) 2121
Answer: (C) Detailed Explanation: Using the variance property Var(aX+b)=a2Var(X)Var(aX + b) = a^2 Var(X): Here a=−2a = -2 and b=5b = 5. Var(5−2X)=(−2)2Var(X)=4×4=16Var(5 - 2X) = (-2)^2 Var(X) = 4 \times 4 = 16.

Question 2 (MSQ)

Which of the following functions F(x)F(x) represent valid Cumulative Distribution Functions for some random variable XX?
  • (A) F(x)=0F(x) = 0 for x<0x < 0, F(x)=0.5F(x) = 0.5 for 0≤x<10 \le x < 1, F(x)=1F(x) = 1 for x≥1x \ge 1.
  • (B) F(x)=1−e−xF(x) = 1 - e^{-x} for x∈Rx \in \mathbb{R}.
  • (C) F(x)=0F(x) = 0 for x<0x < 0, F(x)=x/2F(x) = x/2 for 0≤x<20 \le x < 2, F(x)=1F(x) = 1 for x≥2x \ge 2.
  • (D) F(x)=0.2F(x) = 0.2 for x<1x < 1, F(x)=0.8F(x) = 0.8 for 1≤x<21 \le x < 2, F(x)=1.2F(x) = 1.2 for x≥2x \ge 2.
Explanation:
  • (A) Valid discrete CDF: ranges from 0 to 1, right-continuous, non-decreasing.
  • (B) Invalid: for x<0x < 0, 1−e−x1 - e^{-x} is negative (e.g. at x=−1x=-1, 1−e≈−1.718<01-e \approx -1.718 < 0).
  • (C) Valid continuous CDF: non-decreasing, limits are 0 and 1.
  • (D) Invalid: probabilities cannot exceed 1 (F(x)F(x) hits 1.2).

10. Active Recall Flashcards

  1. How do you find the probability mass P(X=c)P(X = c) from a CDF F(x)F(x)? Answer: Measure the height of the jump at cc: P(X=c)=F(c)−lim⁡x→c−F(x)P(X = c) = F(c) - \lim_{x \to c^-} F(x).
  2. What are the two conditions that every PMF p(x)p(x) must satisfy? Answer: (1) p(x)≥0p(x) \ge 0 for all xx, and (2) ∑x∈SXp(x)=1\sum_{x \in S_X} p(x) = 1.
  3. What is the effect of a linear transformation Y=aX+bY = aX + b on the expectation and variance of XX? Answer: E[Y]=aE[X]+bE[Y] = aE[X] + b, and Var(Y)=a2Var(X)Var(Y) = a^2 Var(X).
  4. For an integer-valued random variable, what is P(X≥3)P(X \ge 3) in terms of the CDF F(x)F(x)? Answer: P(X≥3)=1−P(X<3)=1−P(X≤2)=1−F(2)P(X \ge 3) = 1 - P(X < 3) = 1 - P(X \le 2) = 1 - F(2).
Document outline

Keep your place and jump directly to a heading.

Table of contents

No note selected

Open a chapter to see its outline, backlinks, and sources here.