Quiz 2

Week 1.1: Joint Probability Mass Function (Joint PMF)

2240 words
11 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

# Week 1.1: Joint Probability Mass Function (Joint PMF) > **Prerequisites:** BSMA1002 (Stats 1) — Probability, PMF, random variables > **Cross-links:** BSMA3012 (Linear Stat Models) — multivariate analysis > **Core question:** When two or more random variables live in the same experiment, how do we describe their _j...

Week 1.1: Joint Probability Mass Function (Joint PMF)

Prerequisites: BSMA1002 (Stats 1) — Probability, PMF, random variables Cross-links: BSMA3012 (Linear Stat Models) — multivariate analysis Core question: When two or more random variables live in the same experiment, how do we describe their joint behaviour?

1. Intuition: Why Joint Distributions?

In Stats 1, we studied random variables one at a time. But real experiments produce multiple measurements simultaneously:
  • A cricket over: runs scored (XX) and wickets lost (YY)
  • A patient: height (XX) and weight (YY)
  • A stock: today's return (X1X_1), yesterday's return (X2X_2) The value of one variable can influence the other. A wicket tends to reduce runs. Taller people tend to weigh more. Stocks cluster.
Key idea: The joint distribution of XX and YY captures the full probabilistic relationship — not just how each behaves alone, but how they co-vary.

2. Formal Definition

2.1 Joint PMF (Two Discrete RVs)

Suppose XX and YY are discrete random variables defined on the same probability space, with ranges TXT_X and TYT_Y respectively.
Definition (Joint PMF) The joint probability mass function of XX and YY, denoted fXYf_{XY}, is
>fXY(t1,t2)=P(X=t1 and Y=t2),t1TX,  t2TY.>> f_{XY}(t_1, t_2) = \mathbb{P}(X = t_1 \text{ and } Y = t_2), \quad t_1 \in T_X, \; t_2 \in T_Y. >
Properties:
  1. 0fXY(t1,t2)10 \leq f_{XY}(t_1, t_2) \leq 1
  2. t1TXt2TYfXY(t1,t2)=1\displaystyle\sum_{t_1 \in T_X}\sum_{t_2 \in T_Y} f_{XY}(t_1, t_2) = 1
  3. The joint PMF completely determines all probabilistic relationships between XX and YY.
Notation: We write P(X=t1,Y=t2)\mathbb{P}(X = t_1, Y = t_2) as shorthand for P(X=t1 and Y=t2)\mathbb{P}(X = t_1 \text{ and } Y = t_2).

3. Visualising Joint PMF: The Contingency Table

The joint PMF is most commonly displayed as a two-way table (also called a contingency table). Rows correspond to values of YY, columns to values of XX:
X\YX \backslash Yy1y_1y2y_2\dotsymy_m
x1x_1p11p_{11}p12p_{12}\dotsp1mp_{1m}
x2x_2p21p_{21}p22p_{22}\dotsp2mp_{2m}
\vdots\vdots\vdots\ddots\vdots
xnx_npn1p_{n1}pn2p_{n2}\dotspnmp_{nm}
where pij=P(X=xi,Y=yj)p_{ij} = \mathbb{P}(X = x_i, Y = y_j) and i,jpij=1\sum_{i,j} p_{ij} = 1.

4. Worked Examples

Example 1: Toss a Fair Coin Twice

Let X1=1X_1 = 1 if first toss is heads (0 otherwise), X2=1X_2 = 1 if second toss is heads (0 otherwise). Since the coin is fair and tosses are independent, each of the 4 outcomes has probability 1/41/4. Joint PMF table:
X2\X1X_2 \backslash X_101
01/41/41/41/4
11/41/41/41/4
Verification: Sum of all entries =1/4+1/4+1/4+1/4=1= 1/4 + 1/4 + 1/4 + 1/4 = 1. ✓

Example 2: Random 2-Digit Number (00–99)

Select a number uniformly from {00,01,,99}\{00, 01, \dots, 99\}. Define:
  • XX = digit in the units place (0–9)
  • YY = remainder when the number is divided by 4 (0–3)
Question: What is P(X=0,Y=0)\mathbb{P}(X = 0, Y = 0)? Solution: We need numbers ending in 0 that are divisible by 4. Numbers ending in 0 that are multiples of 4: {00,20,40,60,80}\{00, 20, 40, 60, 80\} — 5 numbers.
fXY(0,0)=5100=120f_{XY}(0, 0) = \frac{5}{100} = \frac{1}{20}
Full joint PMF table:
Y\XY \backslash X0123456789
01/2001/2001/2001/2001/200
101/2001/2001/2001/2001/20
21/2001/2001/2001/2001/200
301/2001/2001/2001/2001/20
Observations:
  • XX and YY are not independent — knowing XX tells us something about YY (e.g., if XX is odd, YY must be odd too).
  • Both marginals are uniform: XUniform{0,,9}X \sim \text{Uniform}\{0,\dots,9\}, YUniform{0,1,2,3}Y \sim \text{Uniform}\{0,1,2,3\}.

Example 3: Die Roll + Coin Tosses (Hierarchical Experiment)

Throw a fair die. Let XX be the number shown. Toss a fair coin XX times. Let YY be the number of heads. Step 1 — Marginal of XX: XUniform{1,2,3,4,5,6}X \sim \text{Uniform}\{1, 2, 3, 4, 5, 6\}, so fX(t)=16f_X(t) = \frac{1}{6}. Step 2 — Conditional of YY given X=tX = t: Given X=tX = t, we toss a coin tt times, so
(YX=t)Binomial(t,12)(Y \mid X = t) \sim \text{Binomial}\left(t, \frac{1}{2}\right) fYX=t(y)=(ty)(12)t,y=0,1,,t.f_{Y \mid X = t}(y) = \binom{t}{y} \left(\frac{1}{2}\right)^t, \quad y = 0, 1, \dots, t.
Step 3 — Joint PMF: Using the factorization fXY(t,y)=fX(t)fYX=t(y)f_{XY}(t, y) = f_X(t) \cdot f_{Y \mid X = t}(y),
fXY(t,y)=16(ty)(12)t,t=1,,6,  y=0,,t.f_{XY}(t, y) = \frac{1}{6} \cdot \binom{t}{y} \left(\frac{1}{2}\right)^t, \quad t = 1,\dots,6,\; y = 0,\dots,t.
For instance:
fXY(3,1)=16(31)(12)3=16318=348=116.f_{XY}(3, 1) = \frac{1}{6} \cdot \binom{3}{1} \left(\frac{1}{2}\right)^3 = \frac{1}{6} \cdot 3 \cdot \frac{1}{8} = \frac{3}{48} = \frac{1}{16}.

5. Joint PMF for More Than Two RVs

The definition extends naturally to nn random variables X1,X2,,XnX_1, X_2, \dots, X_n:
Definition (Joint PMF for nn RVs)
>fX1Xn(t1,,tn)=P(X1=t1,,Xn=tn),tiTXi.>> f_{X_1 \dots X_n}(t_1, \dots, t_n) = \mathbb{P}(X_1 = t_1, \dots, X_n = t_n), \quad t_i \in T_{X_i}. >
Example — Toss a fair coin thrice:
X1X_1X2X_2X3X_3fX1X2X3f_{X_1X_2X_3}
0001/8
0011/8
0101/8
0111/8
1001/8
1011/8
1101/8
1111/8

6. Formula Summary

ConceptFormulaExample
Joint PMF (2 RVs)P(X=x,Y=y)=fXY(x,y)\mathbb{P}(X = x, Y = y) = f_{XY}(x, y)Coin toss: fX1X2(0,0)=1/4f_{X_1X_2}(0,0) = 1/4
Total probabilityxyfXY(x,y)=1\sum_x \sum_y f_{XY}(x,y) = 1i=01j=011/4=1\sum_{i=0}^1\sum_{j=0}^1 1/4 = 1
FactorizationfXY(x,y)=fX(x)fYX=x(y)f_{XY}(x,y) = f_X(x) \cdot f_{Y \mid X = x}(y)Die+coin: 1/6(ty)(1/2)t1/6 \cdot \binom{t}{y}(1/2)^t
Joint PMF ( nn RVs)fX1Xn(t1,,tn)=P(iXi=ti)f_{X_1\dots X_n}(t_1,\dots,t_n) = \mathbb{P}(\bigcap_i X_i = t_i)Triple coin: each outcome =1/8=1/8

7. Practice Questions

Q1 (Easy)

A fair coin is tossed 3 times. Let XX = number of heads in first 2 tosses, YY = number of heads in last 2 tosses. Find the joint PMF of XX and YY.
Strategy Hint
List all 8 outcomes. Count heads in positions (1,2) for XX, positions (2,3) for YY. Full Solution
Sample space: {HHH,HHT,HTH,HTT,THH,THT,TTH,TTT}\{HHH, HHT, HTH, HTT, THH, THT, TTH, TTT\}, each with probability 1/81/8.
Compute (X,Y)(X, Y) for each:
OutcomeXXYY
HHH22
HHT21
HTH11
HTT10
THH12
THT11
TTH01
TTT00
Now count joint probabilities:
X\YX \backslash Y012
01/81/80
11/82/81/8
201/81/8
Check: sum =1/8+1/8+1/8+2/8+1/8+1/8+1/8=8/8=1= 1/8 + 1/8 + 1/8 + 2/8 + 1/8 + 1/8 + 1/8 = 8/8 = 1. ✓

Q2 (Medium)

A random 3-digit number from 000 to 999 is selected uniformly. Define XX = first digit (hundreds place), YY = number modulo 2, ZZ = last digit (units place). Find P(X=0,Y=0,Z=0)\mathbb{P}(X = 0, Y = 0, Z = 0).
Strategy Hint
X=0X=0 means the number is in 000–099. Y=0Y=0 means even. Z=0Z=0 means ends in 0. Count numbers in 000–099 that are even and end in 0. Full Solution
Numbers in 000–099 are {00,01,,99}\{00, 01, \dots, 99\} (100 numbers). Among these, those ending in 0 and even: {00,10,20,30,40,50,60,70,80,90}\{00, 10, 20, 30, 40, 50, 60, 70, 80, 90\} — 10 numbers.
>P(X=0,Y=0,Z=0)=101000=1100.>> \mathbb{P}(X=0, Y=0, Z=0) = \frac{10}{1000} = \frac{1}{100}. >
Alternatively, compute via independence: XX and ZZ are independent uniform {0,,9}\{0,\dots,9\}, YY depends on ZZ only. fXYZ(0,0,0)=fX(0)fZ(0)P(Y=0Z=0)=(1/10)(1/10)(1)=1/100f_{XYZ}(0,0,0) = f_X(0) \cdot f_{Z}(0) \cdot \mathbb{P}(Y=0 \mid Z=0) = (1/10)(1/10)(1) = 1/100.

Q3 (Hard — IPL Data)

In an IPL powerplay over, let XX = number of runs, YY = number of wickets. Suppose:
Y{1316,18,116} with values {0,1,2}Y \sim \left\{ \frac{13}{16}, \frac{1}{8}, \frac{1}{16} \right\} \text{ with values } \{0, 1, 2\} (XY=0)Uniform{6,7,8,9,10,11,12}(X \mid Y=0) \sim \text{Uniform}\{6,7,8,9,10,11,12\} (XY=1)Uniform{2,3,4,5,6,7,8}(X \mid Y=1) \sim \text{Uniform}\{2,3,4,5,6,7,8\} (XY=2)Uniform{0,1,2,3,4,5,6}(X \mid Y=2) \sim \text{Uniform}\{0,1,2,3,4,5,6\}
Find P(X=6,Y=0)\mathbb{P}(X = 6, Y = 0) and P(X=6)\mathbb{P}(X = 6).
Strategy Hint
Use factorization fXY(x,y)=fY(y)fXY=y(x)f_{XY}(x,y) = f_Y(y) \cdot f_{X \mid Y=y}(x). For P(X=6)\mathbb{P}(X=6), sum over all yy. Full Solution
Part 1: P(X=6,Y=0)\mathbb{P}(X=6, Y=0)
>fXY(6,0)=fY(0)fXY=0(6)=131617=13112.>> f_{XY}(6,0) = f_Y(0) \cdot f_{X \mid Y=0}(6) = \frac{13}{16} \cdot \frac{1}{7} = \frac{13}{112}. >
Part 2: P(X=6)\mathbb{P}(X=6)
>P(X=6)=fXY(6,0)+fXY(6,1)+fXY(6,2)=131617+1817+11617=13112+156+1112=13+2+1112=16112=17.>> \begin{aligned} \mathbb{P}(X=6) &= f_{XY}(6,0) + f_{XY}(6,1) + f_{XY}(6,2) \\ &= \frac{13}{16}\cdot\frac{1}{7} + \frac{1}{8}\cdot\frac{1}{7} + \frac{1}{16}\cdot\frac{1}{7} \\ &= \frac{13}{112} + \frac{1}{56} + \frac{1}{112} \\ &= \frac{13 + 2 + 1}{112} = \frac{16}{112} = \frac{1}{7}. \end{aligned} >
So P(X=6)=1/7\mathbb{P}(X=6) = 1/7.

Q4 (Easy)

For the random 2-digit number example (Example 2), verify that x=09y=03fXY(x,y)=1\sum_{x=0}^9 \sum_{y=0}^3 f_{XY}(x,y) = 1.
Full Solution
From the table: each of the 40 cells has probability 1/201/20 or 00. The non-zero cells are exactly those where xx mod 2 = yy mod 2 (both even or both odd). There are 20 such cells (5 even xx values ×\times 2 even yy values + 5 odd xx values ×\times 2 odd yy values). Each has 1/201/20.
Sum =20×1/20=1= 20 \times 1/20 = 1. ✓

Q5 (Medium)

For the triple coin toss, find the joint PMF of X=X1+X2X = X_1 + X_2 (sum of first two) and Y=X2+X3Y = X_2 + X_3 (sum of last two).
Strategy Hint
List all 8 outcomes, compute (X,Y)(X,Y) for each, then count frequencies. Full Solution
Outcomes: HHH→(2,2), HHT→(2,1), HTH→(1,1), HTT→(1,0), THH→(1,2), THT→(1,1), TTH→(0,1), TTT→(0,0).
Joint PMF table:
X\YX \backslash Y012
01/81/80
11/82/81/8
201/81/8
Sum =8/8=1= 8/8 = 1. ✓

Q6 (Hard)

Let XUniform{1,2,3}X \sim \text{Uniform}\{1,2,3\} and independently YUniform{1,2}Y \sim \text{Uniform}\{1,2\}. Find the joint PMF of XX and YY.
Full Solution
Since XX and YY are independent: fXY(x,y)=fX(x)fY(y)f_{XY}(x,y) = f_X(x) \cdot f_Y(y).
fX(x)=1/3f_X(x) = 1/3 for x=1,2,3x = 1,2,3. fY(y)=1/2f_Y(y) = 1/2 for y=1,2y = 1,2.
So fXY(x,y)=1/31/2=1/6f_{XY}(x,y) = 1/3 \cdot 1/2 = 1/6 for all x{1,2,3},y{1,2}x \in \{1,2,3\}, y \in \{1,2\}.
Y\XY \backslash X123
11/61/61/6
21/61/61/6
Check: 3×2×1/6=13 \times 2 \times 1/6 = 1. ✓

Q7 (Exam-style)

A fair die is rolled twice. Let XX = maximum of the two rolls, YY = minimum of the two rolls. Find P(X=5,Y=3)\mathbb{P}(X = 5, Y = 3).
Strategy Hint
The ordered pairs that give max=5, min=3 are (3,5) and (5,3). Count the unordered outcomes carefully. Full Solution
There are 6×6=366 \times 6 = 36 equally likely ordered outcomes.
X=5,Y=3X=5, Y=3 occurs when the two rolls are 3 and 5. The ordered pairs are (3,5)(3,5) and (5,3)(5,3).
>P(X=5,Y=3)=236=118.>> \mathbb{P}(X=5, Y=3) = \frac{2}{36} = \frac{1}{18}. >

Q8 (Medium)

For the 2-digit number example, compute P(X4,Y=1)\mathbb{P}(X \leq 4, Y = 1).
Full Solution
Y=1Y=1 means the number modulo 4 is 1. X4X \leq 4 means units digit is 0,1,2,3,4.
From the joint PMF table, for Y=1Y=1:
  • X=0X=0: 0
  • X=1X=1: 1/20
  • X=2X=2: 0
  • X=3X=3: 1/20
  • X=4X=4: 0
Sum =1/20+1/20=1/10= 1/20 + 1/20 = 1/10.

Q9 (Hard — Three RVs)

Let X1,X2,X3X_1, X_2, X_3 be i.i.d. Bernoulli(pp). Find the joint PMF and verify it sums to 1.
Full Solution
Since XiX_i are independent and identically distributed Bernoulli(pp):
>P(Xi=0)=1p,P(Xi=1)=p.>> \mathbb{P}(X_i = 0) = 1-p, \quad \mathbb{P}(X_i = 1) = p. >
Joint PMF (using independence):
>fX1X2X3(t1,t2,t3)=pti(1p)3ti.>> f_{X_1X_2X_3}(t_1, t_2, t_3) = p^{\sum t_i} (1-p)^{3 - \sum t_i}. >
Sum over all 8 outcomes:
>(t1,t2,t3){0,1}3pti(1p)3ti=(p+(1p))3=13=1.>> \sum_{(t_1,t_2,t_3) \in \{0,1\}^3} p^{\sum t_i} (1-p)^{3-\sum t_i} = (p + (1-p))^3 = 1^3 = 1. >
where the identity k=03(3k)pk(1p)3k=(p+(1p))3\sum_{k=0}^3 \binom{3}{k} p^k (1-p)^{3-k} = (p+(1-p))^3 is used.

Q10 (Exam-style)

For the IPL example (Q3), find P(Y=0X=8)\mathbb{P}(Y=0 \mid X=8).
Strategy Hint
Use Bayes' theorem: P(Y=0X=8)=fXY(8,0)/fX(8)\mathbb{P}(Y=0 \mid X=8) = f_{XY}(8,0) / f_X(8). Compute fX(8)f_X(8) by summing over YY. Full Solution
First compute fX(8)f_X(8):
>fX(8)=fXY(8,0)+fXY(8,1)+fXY(8,2)=131617+1817+11617=13112+2112+1112=16112=17.>> \begin{aligned} f_X(8) &= f_{XY}(8,0) + f_{XY}(8,1) + f_{XY}(8,2) \\ &= \frac{13}{16}\cdot\frac{1}{7} + \frac{1}{8}\cdot\frac{1}{7} + \frac{1}{16}\cdot\frac{1}{7} \\ &= \frac{13}{112} + \frac{2}{112} + \frac{1}{112} = \frac{16}{112} = \frac{1}{7}. \end{aligned} >
Now:
>P(Y=0X=8)=fXY(8,0)fX(8)=13/1121/7=1311271=1316.>> \mathbb{P}(Y=0 \mid X=8) = \frac{f_{XY}(8,0)}{f_X(8)} = \frac{13/112}{1/7} = \frac{13}{112} \cdot \frac{7}{1} = \frac{13}{16}. >
Next topic: Week 1.2: Marginal Distributions — Summing over rows and columns to get marginal PMFs. Join Discord NextWeek 1.2: Marginal Distributions
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.