Weeks
Statistics 2Week 1 · Multiple Random Variables
Week 1 Notes

Statistics for
Data Science 2

Multiple random variables: joint, marginal and conditional PMFs, with every worked example and every graded-assignment question solved where it fits.

10 chapters47 worked examples~50 min read
Joint PMFMarginal PMFConditional PMFTotal probabilityFactoring

Chapters

  1. 01Why We Need Multiple Random VariablesPart 1
  2. 02Joint PMF of Two Random VariablesPart 2
  3. 03Marginal PMFPart 3
  4. 04Conditional PMFPart 4
  5. 05Law of Total Probability with DistributionsPart 5
  6. 06Many Random Variables: Joint and Marginal PMFsPart 6
  7. 07Conditioning with Multiple Random VariablesPart 7
  8. 08Factoring the Joint PMFPart 8
  9. 09Extra Practice ProblemsPractice
  10. 10Week 1 Summary SheetAll parts
01
Part 1

Why We Need Multiple Random Variables

Most experiments produce several numbers at once, and those numbers are often related. This week builds the tools to describe such relationships.

1.1Why one random variable is not enough

  • Most real experiments produce several related quantities at once.
  • This week builds tools to describe several random variables on the same probability space, and how they relate to each other.

Example: toss a coin thrice

Xi=1X_i = 1 if toss ii is Heads, 00 if Tails, i=1,2,3i = 1, 2, 3. All three are defined on the same three tosses, so they live on the same probability space. Together X1,X2,X3X_1, X_2, X_3 fully describe the outcome. Here they are independent of each other; this will not always be true.

Toss a coin thrice: X_i = 1 if toss i is Heads, 0 if TailsX₁toss 1X₂toss 2X₃toss 3all three live on the same three tosses: one probability spacetogether X₁, X₂, X₃ fully describe the outcome (here they are independent; this will not always be true)
Figure 1. Three random variables on the same three tosses

Example: a random 2-digit number

Pick a 2-digit number 0000–9999. XX = units digit, YY = remainder mod 4. Direct counting shows X∼Uniform{0,…,9}X \sim \text{Uniform}\{0, \dots, 9\} and Y∼Uniform{0,1,2,3}Y \sim \text{Uniform}\{0, 1, 2, 3\}.

The key catch

If X=1X = 1 (the number ends in 1, so it is odd), then Y=0Y = 0 is impossible: a multiple of 4 is always even. So XX and YY are not independent: knowing XX changes what is possible for YY.

Example: an IPL powerplay over

XX = runs in an over, YY = wickets in the over. Intuition: if Y=0Y = 0 (no wicket), XX tends to be larger, because the batting side was not interrupted. Modelling exactly this kind of dependency is the goal of the chapter.

IPL powerplay over: X = runs, Y = wicketsY = 0no wicket: batting side not interruptedX tends to be largerY ≥ 1wickets fallX tends to be smallerone variable changes what we can say about the other: joint, marginal and conditional PMFs capture this
Figure 2. Runs and wickets in an over depend on each other
The whole point of the topic

Sometimes one random variable changes what you can say about another. Joint, marginal and conditional distributions are the tools that capture that relationship.

Example 1Spot the dependence

A fair die is thrown once. XX = the number shown, Y=1Y = 1 if the number is even and 00 otherwise. Are XX and YY independent?

Solution

No. If X=3X = 3 then Y=0Y = 0 for sure; if X=4X = 4 then Y=1Y = 1 for sure. Knowing XX completely determines YY, so they are as dependent as two variables can be.

1.2Going deeper: random variables on one experiment

  • A random variable is a function of the outcome. Several random variables on one experiment are several functions of the same outcome. For three tosses, X1,X2,X3X_1, X_2, X_3 are the tosses, and S=X1+X2+X3S = X_1 + X_2 + X_3 (number of Heads) is one more random variable on the same space.
  • Independent means no information is carried. XX and YY are independent when learning XX never changes what you can say about YY. In terms of the PMFs, fXY=fXfYf_{XY} = f_X f_Y in every cell.
  • If one determines the other, they are dependent. If YY is a function of XX (like "even or odd" of a die roll), then knowing XX fixes YY, so they are dependent unless YY is a constant.
  • The fastest proof of dependence is one impossible combination: P(X=a,Y=b)=0P(X = a, Y = b) = 0 although P(X=a)>0P(X = a) > 0 and P(Y=b)>0P(Y = b) > 0.
  • Three or more variables. Mutual independence means the whole joint factorises: f(t1,t2,t3)=f(t1)f(t2)f(t3)f(t_1, t_2, t_3) = f(t_1) f(t_2) f(t_3). The joint PMF, not the separate PMFs, carries the relationships.

1.3Exam tips and common mistakes

Exam tips
  • To show dependence, find one impossible combination or one cell where the product rule fails.
  • To show independence, you must check every cell (or give a structural reason such as separate tosses).
  • Say which experiment the random variables live on before comparing them.
Common mistakes
  • Assuming two variables are independent because their names look unrelated. Use the table.
  • Checking only one cell and declaring independence.
  • Forgetting that a variable that is a function of another is dependent on it.

Practice questions (graded-assignment style)

Q1Which pair is independent?

Multiple Choice Question (MCQ): choose the one correct option.

Two fair dice are thrown. Which pair of random variables is independent?

1
XX = first die, YY = sum of the two dice
2
XX = first die, YY = second die
3
XX = larger of the two, YY = smaller of the two
4
XX = first die, Y=2XY = 2X
Solution
Idea

Independent variables come from separate, non-interacting parts of the experiment.

  • Option 1: if the first die is 6 the sum is at least 7, so the first die changes the sum.
  • Option 2: the two throws do not influence each other, so they are independent.
  • Option 3: if the larger is 1 the smaller must be 1, so they depend on each other.
  • Option 4: YY is a function of XX, so it is dependent.
  • Answer: option 2.
Q2Tens and units digits

Multiple Choice Question (MCQ): choose the one correct option.

A number is picked uniformly from 00,01,…,9900, 01, \dots, 99. XX = tens digit, YY = units digit. Which statement is true?

1
They are dependent, because they come from the same number.
2
They are independent, because every cell has 1100=110⋅110\frac{1}{100} = \frac{1}{10} \cdot \frac{1}{10}.
3
They are dependent, because XX decides YY.
4
They are independent only if the number is even.
Solution
Idea

Test the product rule, not the story.

  • All 100 pairs (tens, units) are equally likely, so each cell is 1/100.
  • Each digit is uniform on {0,…,9}\{0, \dots, 9\}, so fXfY=110⋅110=1100f_X f_Y = \frac{1}{10} \cdot \frac{1}{10} = \frac{1}{100} in every cell.
  • Answer: option 2.
Q3One variable from the other

Multiple Select Question (MSQ): select all that apply.

A fair die is thrown. XX = the number shown, Y=1Y = 1 if XX is even and 00 otherwise. Choose the correct statements.

1
Knowing XX decides YY.
2
P(Y=1∣X=4)=1P(Y = 1 \mid X = 4) = 1.
3
XX and YY are independent.
4
Y∼Bernoulli(12)Y \sim \text{Bernoulli}(\tfrac{1}{2}).
Solution
Idea

Check what each statement says about the table.

  • Option 1 is true: YY is a function of XX.
  • Option 2 is true: 4 is even.
  • Option 3 is false: for example P(X=3,Y=1)=0P(X = 3, Y = 1) = 0 while P(X=3)>0P(X = 3) > 0 and P(Y=1)>0P(Y = 1) > 0.
  • Option 4 is true: 3 of the 6 faces are even.
  • Answer: options 1, 2 and 4.
Q4An impossible cell

Multiple Choice Question (MCQ): choose the one correct option.

P(X=1)>0P(X = 1) > 0 and P(Y=0)>0P(Y = 0) > 0, but P(X=1,Y=0)=0P(X = 1, Y = 0) = 0. What follows?

1
XX and YY are independent.
2
XX and YY are dependent.
3
Nothing can be said.
4
YY is a constant.
Solution
Idea

Compare with the product rule.

  • Independence needs P(X=1,Y=0)=P(X=1)P(Y=0)>0P(X = 1, Y = 0) = P(X = 1) P(Y = 0) > 0.
  • The cell is 0, so the product rule fails and the variables are dependent.
  • Answer: option 2.
Revision overview
Same probability spaceSeveral random variables defined on one experiment
Coin thrice: X₁, X₂, X₃
Independent?Coin tosses: yes
Not always true
Why Multiple VariablesWeek 1 · Part 1
2-digit numberX = units digit, Y = mod 4
X = 1 makes Y = 0 impossible
So not independent
The toolsJoint, marginal, conditional PMFs
capture the relationship
Revision: why we need several random variables, on one page
Next · Part 2Joint PMF of Two Random Variables
02
Part 2

Joint PMF of Two Random Variables

The joint PMF gives the probability of every pair of values at once. It is the complete description of two random variables on the same experiment.

2.1The joint PMF

Definition: joint PMF
fXY(t1,t2)=P(X=t1, Y=t2),t1∈TX,  t2∈TYf_{XY}(t_1, t_2) = P(X = t_1,\, Y = t_2), \qquad t_1 \in T_X,\; t_2 \in T_Y

It is usually shown as a table: XX's values across the top, YY's values down the side.

Two properties
  • Every entry is between 0 and 1.
  • All entries add up to 1.
fXY(t₁, t₂) = P(X = t₁, Y = t₂)Rules for any joint PMFevery entry is between 0 and 1all entries add up to 1ΣΣ fXY(t₁, t₂) = 1Shown as a tableX values across the topY values down the sideeach cell = P(X = x, Y = y)
Figure 3. What a joint PMF is, and the two rules it must obey
Comma means "and". P(X=t1,Y=t2)P(X = t_1, Y = t_2) is the probability of the event (X=t1)∩(Y=t2)(X = t_1) \cap (Y = t_2). Summing a joint PMF over a region of the table gives the probability of that region.

Example: toss a fair coin twice

X1,X2X_1, X_2 mark Heads (1) / Tails (0) on two independent tosses. fX1X2(0,0)=P(X1=0) P(X2=0)=12×12=14f_{X_1X_2}(0, 0) = P(X_1 = 0)\,P(X_2 = 0) = \frac{1}{2} \times \frac{1}{2} = \frac{1}{4}, and the same logic gives every other cell.

Fair coin tossed twiceX1X20101/41/411/41/4f(0,0) = P(X₁=0)·P(X₂=0)= 1/2 × 1/2 = ¼independent tosses: multiplyevery other cell works the same way
Figure 4. Independent fair tosses: every cell is 1/4

Example: a random 2-digit number

  • fXY(0,0)f_{XY}(0, 0): units digit 0 and divisible by 4 gives {00,20,40,60,80}\{00, 20, 40, 60, 80\}, so 5100=120\frac{5}{100} = \frac{1}{20}.
  • fXY(1,0)f_{XY}(1, 0): units digit 1 can never make a multiple of 4, so 00.
  • fXY(4,2)f_{XY}(4, 2): {14,34,54,74,94}\{14, 34, 54, 74, 94\}, so 5100=120\frac{5}{100} = \frac{1}{20}.

Every cell works out to 00 or 120\frac{1}{20}. There are 10×4=4010 \times 4 = 40 cells in the table, and exactly 20 of them are nonzero: for each units digit, the tens digit can only produce two different remainders mod 4. And 20×120=120 \times \frac{1}{20} = 1: a valid joint PMF.

A random 2-digit number: X = units digit, Y = remainder mod 4XY012345678901/2001/2001/2001/2001/200101/2001/2001/2001/2001/2021/2001/2001/2001/2001/200301/2001/2001/2001/2001/201/201/201/201/201/201/201/201/201/201/201/201/201/201/201fYfX20 cells have probability 1/20 (20 × 1/20 = 1); the other 20 are impossible
Figure 5. The joint PMF of the units digit and the remainder mod 4
A correction. The source notes say "the 40 nonzero cells sum to 1". That cannot be: 40 cells of 120\frac{1}{20} would sum to 2. The table has 40 cells in total, of which 20 are nonzero.

2.2Going deeper: using a joint PMF table

  • Reading regions. The probability of any event about (X,Y)(X, Y) is the sum of the cells it contains. For P(X+Y=3)P(X + Y = 3), add the cells on the diagonal where the coordinates sum to 3; for P(X<Y)P(X < Y), add the cells above the diagonal.
  • Finding unknown constants. Step 1: all cells add to 1. Step 2: if a probability is given, write it as a second sum. Step 3: solve the two equations together (as in GA Q7).
  • A function of two variables. To get the PMF of Z=g(X,Y)Z = g(X, Y), group the cells by the value of gg and add each group. For two fair coins, Z=X1+X2Z = X_1 + X_2 gives P(Z=0)=14P(Z = 0) = \frac{1}{4}, P(Z=1)=12P(Z = 1) = \frac{1}{2}, P(Z=2)=14P(Z = 2) = \frac{1}{4}.
  • Building a table. If the variables are independent, multiply marginals. If the experiment is a selection without replacement, count: fXY(x,y)=(ax)(by)(cn−x−y)(Nn)f_{XY}(x, y) = \frac{\binom{a}{x}\binom{b}{y}\binom{c}{n - x - y}}{\binom{N}{n}}.
  • Size of the table. ∣TX∣×∣TY∣|T_X| \times |T_Y| cells. Many may be 0, and the nonzero ones must still add up to 1.

2.3Exam tips and common mistakes

Exam tips
  • Always verify that all cells add up to 1 before using the table.
  • Write the region as a list of cells first, then add them.
  • For selection problems, divide by the total number of ways, (Nn)\binom{N}{n}.
Common mistakes
  • Multiplying marginals to fill a table when the variables are not independent.
  • Adding cells for the wrong region (for example X≥1X \ge 1 instead of X>1X > 1).
  • Forgetting that the normalising sum covers all cells, including those equal to 0.

Practice questions (graded-assignment style)

Q1Find the constant

Numerical Answer Type (NAT).

fXY(x,y)=x+ykf_{XY}(x, y) = \frac{x + y}{k} for x,y∈{1,2}x, y \in \{1, 2\}. Find kk.

Solution
Idea

All cells add up to 1.

  • The numerators are 2,3,3,42, 3, 3, 4, which add up to 12.
  • So 12k=1\frac{12}{k} = 1 and k=12k = 12.
  • Answer: 12
Q2A diagonal probability

Numerical Answer Type (NAT).

With the same fXY(x,y)=x+y12f_{XY}(x, y) = \frac{x + y}{12}, find P(X+Y=3)P(X + Y = 3).

Solution
Idea

Add the cells where x+y=3x + y = 3.

  • The cells are (1,2)(1, 2) and (2,1)(2, 1), each with numerator 3.
  • P=3+312=12P = \frac{3 + 3}{12} = \frac{1}{2}.
  • Answer: 0.5
Q3PMF of a sum

Multiple Choice Question (MCQ): choose the one correct option.

Two fair coins are tossed independently. X1,X2X_1, X_2 are 1 for Heads and 0 for Tails. What is the PMF of Z=X1+X2Z = X_1 + X_2 at z=0,1,2z = 0, 1, 2?

1
13,13,13\frac{1}{3}, \frac{1}{3}, \frac{1}{3}
2
14,12,14\frac{1}{4}, \frac{1}{2}, \frac{1}{4}
3
12,0,12\frac{1}{2}, 0, \frac{1}{2}
4
12,14,14\frac{1}{2}, \frac{1}{4}, \frac{1}{4}
Solution
Idea

Group the four equally likely cells by the value of the sum.

  • Z=0Z = 0: only (0, 0), so 14\frac{1}{4}.
  • Z=1Z = 1: (0, 1) and (1, 0), so 24\frac{2}{4}.
  • Z=2Z = 2: only (1, 1), so 14\frac{1}{4}.
  • Answer: option 2.
Q4Valid joint PMFs

Multiple Select Question (MSQ): select all that apply.

A joint PMF has four cells. Which lists of cell values are valid?

1
0.2, 0.3, 0.1, 0.4
2
0.5, 0.3, 0.3, −0.1-0.1
3
0.25, 0.25, 0.25, 0.25
4
0.3, 0.3, 0.3, 0.3
Solution
Idea

Every cell is in [0, 1] and they add to 1.

  • List 1: all in range, sum 1.0, valid.
  • List 2: a negative entry, invalid.
  • List 3: sum 1.0, valid.
  • List 4: sum 1.2, invalid.
  • Answer: options 1 and 3.
Q5Draw without replacement

Numerical Answer Type (NAT).

A bag has 3 red, 2 blue and 1 green ball. Two balls are drawn without replacement. XX = number of red, YY = number of blue. Find fXY(1,1)f_{XY}(1, 1).

Solution
Idea

Count selections.

  • Total pairs: (62)=15\binom{6}{2} = 15.
  • One red and one blue: 3×2=63 \times 2 = 6.
  • fXY(1,1)=615=0.4f_{XY}(1, 1) = \frac{6}{15} = 0.4.
  • Answer: 0.4
Revision overview
Definitionf_XY(t₁, t₂) = P(X = t₁, Y = t₂)
Table: X across, Y down
PropertiesEach entry in [0, 1]
All entries add up to 1
Fair coin twiceIndependent: multiply
Every cell = ¼
Joint PMFWeek 1 · Part 2
2-digit numberCells are 0 or 1/20
20 nonzero cells sum to 1
f(1, 0) = 0
GA Q7Normalise, use P(...) given
a = 1/42, b = 2
f(1,1) = 1/14
GA Q9, Q1Committee: 2/7
Coins and points: 1/2
Revision: the joint PMF on one page
Next · Part 3Marginal PMF
03
Part 3

Marginal PMF

From the joint PMF we can always recover each variable on its own by summing out the other. The reverse is not possible.

3.1Marginal PMF

Definition: marginal PMF

The PMF of XX alone (ignoring YY) is its marginal PMF. It is found by summing the joint PMF over all values of the other variable. This is called marginalisation.

fX(t)=∑t′fXY(t,t′)fY(t)=∑t′fXY(t′,t)f_X(t) = \sum_{t^{\prime}} f_{XY}(t, t^{\prime}) \qquad f_Y(t) = \sum_{t^{\prime}} f_{XY}(t^{\prime}, t)
One-way street

Joint →\to marginal is unique. Marginal →\to joint is not: many different joint PMFs can share the same marginals (shown below).

Example: toss a fair coin twice

Sum down the columns for fX1f_{X_1}, across the rows for fX2f_{X_2}:

Fair coin tossed twiceX1X20101/41/411/41/41/21/21/21/21fX2fX1sum across each row → fX2sum down each column → fX1fX(t) = Σt′ fXY(t, t′)
Figure 7. Row sums and column sums are the marginals

Example: marginals from a joint PMF

A joint PMF with the marginalsX1X20100.050.3510.250.350.40.60.30.71fX2fX1check: 0.05 + 0.35 + 0.25 + 0.35 = 1 ✓fX2 = (0.40, 0.60)fX1 = (0.30, 0.70)
Figure 8. Check the table adds up to 1, then sum rows and columns

Same marginals, different joints

Both tables below give marginals 12,12\frac{1}{2}, \frac{1}{2} for X1X_1 and X2X_2. Case I (independent): every cell =14= \frac{1}{4}. Case II: for any xx between 00 and 12\frac{1}{2}, f(0,0)=xf(0, 0) = x, f(0,1)=12−xf(0, 1) = \frac{1}{2} - x, f(1,0)=12−xf(1, 0) = \frac{1}{2} - x, f(1,1)=xf(1, 1) = x.

Case I (independent)Case II (any x between 0 and 1/2)X1X20101/41/411/41/41/21/21/21/21fX2fX1X1X201011/21/21/21/21fX2fX1x1/2−x1/2−xxSame marginals (1/2, 1/2), different joints: the marginals alone do not pin down the dependence
Figure 9. Marginals do not pin down the dependence structure
Case II at the extremes. x=14x = \frac{1}{4} is Case I. x=12x = \frac{1}{2} makes X1=X2X_1 = X_2 always (the coins always agree); x=0x = 0 makes them always different. All three have the same marginals.

Example: marginals and an independence check

For the random 2-digit number, summing the table confirms X∼Uniform{0,…,9}X \sim \text{Uniform}\{0, \dots, 9\} and Y∼Uniform{0,1,2,3}Y \sim \text{Uniform}\{0, 1, 2, 3\}, matching the direct counting. Independence would need fXY=fXfYf_{XY} = f_X f_Y in every cell. At (0,0)(0, 0): fXY(0,0)=120f_{XY}(0, 0) = \frac{1}{20} but fX(0)fY(0)=110⋅14=140f_X(0) f_Y(0) = \frac{1}{10} \cdot \frac{1}{4} = \frac{1}{40}. Since 120≠140\frac{1}{20} \neq \frac{1}{40}, they are not independent, matching the earlier intuition.

Test for independence

XX and YY are independent exactly when fXY(t,t′)=fX(t) fY(t′)f_{XY}(t, t^{\prime}) = f_X(t)\, f_Y(t^{\prime}) for every cell. One failing cell is enough to show they are dependent.

Example 2Marginals and independence

The joint PMF of X,Y∈{0,1}X, Y \in \{0, 1\} is f(0,0)=0.1f(0, 0) = 0.1, f(0,1)=0.3f(0, 1) = 0.3, f(1,0)=0.2f(1, 0) = 0.2, f(1,1)=0.4f(1, 1) = 0.4. Find both marginals and decide whether X,YX, Y are independent.

Solution
  • fX(0)=0.1+0.3=0.4f_X(0) = 0.1 + 0.3 = 0.4, fX(1)=0.2+0.4=0.6f_X(1) = 0.2 + 0.4 = 0.6.
  • fY(0)=0.1+0.2=0.3f_Y(0) = 0.1 + 0.2 = 0.3, fY(1)=0.3+0.4=0.7f_Y(1) = 0.3 + 0.4 = 0.7.
  • Check (0,0)(0, 0): fX(0)fY(0)=0.4×0.3=0.12≠0.1f_X(0) f_Y(0) = 0.4 \times 0.3 = 0.12 \neq 0.1. So not independent.

3.2Going deeper: marginals and independence from a table

  • Margins of the table. Add each column to get one marginal and each row to get the other. They are written in the margins, hence the name, and each must add to 1.
  • One-way street. The joint gives the marginals uniquely, but the marginals alone cannot give the joint. Two tables can share the same margins and differ inside (Case I and Case II).
  • Independence gives the joint back. Only when XX and YY are independent can the joint be rebuilt from the marginals, by multiplying: fXY=fXfYf_{XY} = f_X f_Y.
  • Quick dependence test. A zero cell whose row and column marginals are both positive proves dependence at once.
  • Full independence test. Compute fX(t)fY(t′)f_X(t) f_Y(t^{\prime}) for every cell and compare with fXYf_{XY}. Stop at the first mismatch.

3.3Exam tips and common mistakes

Exam tips
  • Add columns for the marginal of XX (across the top) and rows for the marginal of YY (down the side).
  • Always check that each marginal adds up to 1.
  • To prove independence, show the product rule in every cell.
Common mistakes
  • Summing along the wrong direction and getting the marginal of the other variable.
  • Believing that equal marginals mean equal joint tables.
  • Declaring independence after checking a single cell.

Practice questions (graded-assignment style)

Q1A marginal

Numerical Answer Type (NAT).

X,Y∈{0,1}X, Y \in \{0, 1\} with f(0,0)=0.2f(0, 0) = 0.2, f(0,1)=0.2f(0, 1) = 0.2, f(1,0)=0.3f(1, 0) = 0.3, f(1,1)=0.3f(1, 1) = 0.3. Find fX(1)f_X(1).

Solution
Idea

Sum over all values of Y.

  • fX(1)=f(1,0)+f(1,1)=0.3+0.3=0.6f_X(1) = f(1, 0) + f(1, 1) = 0.3 + 0.3 = 0.6.
  • Answer: 0.6
Q2Independent or not?

Multiple Choice Question (MCQ): choose the one correct option.

For the same table, are XX and YY independent?

1
Yes, because the product rule holds in every cell.
2
No, because f(0,0)≠f(1,1)f(0, 0) \neq f(1, 1).
3
No, because the marginals are unequal.
4
Cannot be decided.
Solution
Idea

Compute the marginals first: fX=(0.4,0.6)f_X = (0.4, 0.6) and fY=(0.5,0.5)f_Y = (0.5, 0.5).

  • fX(0)fY(0)=0.4⋅0.5=0.2=f(0,0)f_X(0) f_Y(0) = 0.4 \cdot 0.5 = 0.2 = f(0, 0), and fX(0)fY(1)=0.2=f(0,1)f_X(0) f_Y(1) = 0.2 = f(0, 1).
  • fX(1)fY(0)=0.6⋅0.5=0.3=f(1,0)f_X(1) f_Y(0) = 0.6 \cdot 0.5 = 0.3 = f(1, 0), and fX(1)fY(1)=0.3=f(1,1)f_X(1) f_Y(1) = 0.3 = f(1, 1).
  • All four cells match, so they are independent.
  • Answer: option 1.
Q3Joint and marginal

Multiple Select Question (MSQ): select all that apply.

Choose the correct statements.

1
The joint PMF determines both marginals.
2
The two marginals always determine the joint PMF.
3
A zero cell with both marginals positive shows dependence.
4
If XX and YY are independent, then fXY=fXfYf_{XY} = f_X f_Y.
Solution
Idea

Joint to marginal is one-way.

  • Option 1 is true.
  • Option 2 is false: Case I and Case II share marginals.
  • Option 3 is true: independence would need a positive product.
  • Option 4 is true.
  • Answer: options 1, 3 and 4.
Q4Same marginals, different joint

Numerical Answer Type (NAT).

Case II table with x=0.1x = 0.1: f(0,0)=xf(0, 0) = x, f(0,1)=12−xf(0, 1) = \frac{1}{2} - x, f(1,0)=12−xf(1, 0) = \frac{1}{2} - x, f(1,1)=xf(1, 1) = x. Find f(1,0)f(1, 0).

Solution
Idea

Substitute x.

  • f(1,0)=12−0.1=0.4f(1, 0) = \frac{1}{2} - 0.1 = 0.4.
  • Both marginals are still 12,12\frac{1}{2}, \frac{1}{2}, but X1,X2X_1, X_2 are no longer independent.
  • Answer: 0.4
Revision overview
Marginalisationf_X(t) = Σ f_XY(t, t′)
Sum over the other variable
Row and column sums
One-wayJoint → marginal: unique
Marginal → joint: not unique
Marginal PMFWeek 1 · Part 3
Same marginalsIndependent: all ¼
Case II: x, ½−x, ½−x, x
Different dependence
Independence checkf_XY = f_X · f_Y in every cell
2-digit number: 1/20 ≠ 1/40
Revision: marginal PMFs on one page
Next · Part 4Conditional PMF
04
Part 4

Conditional PMF

Once we know something about one variable, the distribution of another changes. The conditional PMF tells us exactly how: take the relevant slice of the joint and rescale it to total 1.

4.1Conditional PMF

Given an event AfX|A(t) =P((X = t) ∩ A)P(A)the range can differ from that of XGiven another random variablefY|X=t(t′) =fXY(t, t′)fX(t)joint ÷ marginal of what we condition on
Figure 10. Conditioning on an event, and on another random variable

Given an event A

fX∣A(t)=P((X=t)∩A)P(A)f_{X \mid A}(t) = \frac{P\big((X = t) \cap A\big)}{P(A)}

The range of (X∣A)(X \mid A) can differ from the range of XX, depending on what AA restricts.

Given another random variable

fY∣X=t(t′)=fXY(t,t′)fX(t)f_{Y \mid X = t}(t^{\prime}) = \frac{f_{XY}(t, t^{\prime})}{f_X(t)}
Key identity

fXY(t,t′)=fX(t)⋅fY∣X=t(t′)f_{XY}(t, t^{\prime}) = f_X(t) \cdot f_{Y \mid X = t}(t^{\prime}): joint = marginal ×\times conditional.

Example: conditional PMFs from a joint PMF

Joint PMF with its marginalsXY012fY(t₂)01/41/81/81/211/81/81/41/2fX(t₁)3/81/43/81Condition on X = 0 (first column):fY|X=0(0) =1/43/8=23fY|X=0(1) =1/83/8=132/3 + 1/3 = 1 ✓ still a valid PMF
Figure 11. Condition on X = 0: divide the first column by its total 3/8
  • fY∣X=0(0)=1/43/8=23f_{Y \mid X = 0}(0) = \frac{1/4}{3/8} = \frac{2}{3}, fY∣X=0(1)=1/83/8=13f_{Y \mid X = 0}(1) = \frac{1/8}{3/8} = \frac{1}{3} (23+13=1\frac{2}{3} + \frac{1}{3} = 1 ✓: still a valid PMF).
  • fX∣Y=1(0)=1/81/2=14f_{X \mid Y = 1}(0) = \frac{1/8}{1/2} = \frac{1}{4}.
Why it is a valid PMF. Each column of the joint adds up to fX(t)f_X(t), so dividing that column by fX(t)f_X(t) makes its entries add up to 1. A conditional PMF is just a column (or row) of the joint, rescaled to total 1.

4.2Worked problems

Example: throw a die and toss coins

X∼Uniform{1,…,6}X \sim \text{Uniform}\{1, \dots, 6\} and (Y∣X=t)∼Binomial(t,12)(Y \mid X = t) \sim \text{Binomial}(t, \tfrac{1}{2}): throw a die, then toss that many fair coins and let YY be the number of heads. Then fY∣X=t(t′)=(tt′)(12)tf_{Y \mid X = t}(t^{\prime}) = \binom{t}{t^{\prime}}(\tfrac{1}{2})^t, and joint == marginal ×\times conditional:

fXY(t,t′)=16⋅(tt′)(12)tf_{XY}(t, t^{\prime}) = \frac{1}{6} \cdot \binom{t}{t^{\prime}} \left(\frac{1}{2}\right)^t
Throw a die (X), then toss X coins (Y = heads)XY12345600.0830.0420.0210.0100.0050.00310.0830.0830.0620.0420.0260.01620.0420.0620.0620.0520.03930.0210.0420.0520.05240.0100.0260.03950.0050.01660.003fY|X=t= C(t,t′)·(1/2)ᵗfXY = (1/6)·C(t,t′)·(1/2)ᵗjoint = marginal × conditional
Figure 12. Each column is a binomial scaled by 1/6
Takeaway

When "one variable given another" is a familiar named distribution, joint = marginal ×\times conditional builds the whole table without listing raw outcomes.

Example: a Poisson number of coin tosses

N∼Poisson(λ)N \sim \text{Poisson}(\lambda); given N=nN = n, toss a fair coin nn times and let XX = number of Heads. Then

fX(k)=∑n=k∞e−λλnn!(nk)(12)n=∑n=k∞e−λλnk! (n−k)!(12)n=e−λ/2(λ/2)kk!f_X(k) = \sum_{n=k}^{\infty} \frac{e^{-\lambda}\lambda^n}{n!} \binom{n}{k} \left(\frac{1}{2}\right)^n = \sum_{n=k}^{\infty} \frac{e^{-\lambda}\lambda^n}{k!\,(n-k)!} \left(\frac{1}{2}\right)^n = \frac{e^{-\lambda/2}(\lambda/2)^k}{k!}
N ~ Poisson(λ)number of tossesgiven N = ntoss a fair coin n times(Y|N=n) ~ Binomial(n, 1/2)X ~ Poisson(λ/2)heads: the rate halvesfX(k) = Σₙ e−λ λⁿ / (k!(n−k)!) · (1/2)ⁿ = e−λ/2 (λ/2)ᵏ / k!a Poisson "sample size" with fair-coin trials halves the rate
Figure 13. A Poisson count thinned by a fair coin is Poisson with half the rate
How the sum collapses. Pull out e−λ(λ/2)kk!\frac{e^{-\lambda}(\lambda/2)^k}{k!} and substitute m=n−km = n - k: what is left is ∑m≥0(λ/2)mm!=eλ/2\sum_{m \ge 0} \frac{(\lambda/2)^m}{m!} = e^{\lambda/2}, which leaves e−λ/2e^{-\lambda/2}.
Neat result

X∼Poisson(λ/2)X \sim \text{Poisson}(\lambda/2): a Poisson "sample size" with fair-coin trials halves the rate.

4.3Going deeper: conditioning as filtering and rescaling

  • The recipe. To get fY∣X=tf_{Y \mid X = t}, take the column (or row) of the joint where X=tX = t, and divide every entry by that column total fX(t)f_X(t). The new entries add up to 1.
  • Conditioning on an event. Keep only the outcomes in AA and divide by P(A)P(A). The range of (X∣A)(X \mid A) can be smaller than the range of XX.
  • Bayes with PMFs. fX∣Y=y(x)=fY∣X=x(y) fX(x)fY(y)f_{X \mid Y = y}(x) = \frac{f_{Y \mid X = x}(y)\, f_X(x)}{f_Y(y)}, where the denominator comes from total probability. This turns "given the cause, the effect" into "given the effect, the cause".
  • Hierarchical experiments. When stage 2 depends on stage 1 (die, then that many coins), build the joint as marginal ×\times conditional.
  • Thinning (extra). If N∼Poisson(λ)N \sim \text{Poisson}(\lambda) and each of the NN items is kept independently with probability pp, then the number kept is Poisson(λp)\text{Poisson}(\lambda p).
  • Undefined case. Conditioning on a value with probability 0 divides by 0, so it is undefined (the assignment convention reports 0).

4.4Exam tips and common mistakes

Exam tips
  • Write the conditional as "joint ÷ marginal of what is given" before substituting numbers.
  • Check that your conditional PMF adds up to 1.
  • Read the notation: fY∣X=tf_{Y \mid X = t} means the PMF of YY given X=tX = t.
Common mistakes
  • Dividing by the wrong marginal, or swapping fY∣Xf_{Y \mid X} and fX∣Yf_{X \mid Y}.
  • Forgetting to rescale, so the entries of the "conditional" do not add up to 1.
  • Conditioning on an impossible value as if it were fine.

Practice questions (graded-assignment style)

Q1A conditional from a table

Numerical Answer Type (NAT).

X,Y∈{0,1}X, Y \in \{0, 1\} with f(0,0)=14f(0, 0) = \frac{1}{4}, f(0,1)=18f(0, 1) = \frac{1}{8}, f(1,0)=18f(1, 0) = \frac{1}{8}, f(1,1)=12f(1, 1) = \frac{1}{2}. Find fY∣X=1(1)f_{Y \mid X = 1}(1).

Solution
Idea

Take the column X = 1 and divide by its total.

  • fX(1)=18+12=58f_X(1) = \frac{1}{8} + \frac{1}{2} = \frac{5}{8}.
  • fY∣X=1(1)=1/25/8=45=0.8f_{Y \mid X = 1}(1) = \frac{1/2}{5/8} = \frac{4}{5} = 0.8.
  • Answer: 0.8
Q2The conditional formula

Multiple Choice Question (MCQ): choose the one correct option.

Which formula gives fY∣X=t(t′)f_{Y \mid X = t}(t^{\prime})?

1
fXY(t,t′)fX(t)\dfrac{f_{XY}(t, t^{\prime})}{f_X(t)}
2
fXY(t,t′)fY(t′)\dfrac{f_{XY}(t, t^{\prime})}{f_Y(t^{\prime})}
3
fX(t) fY(t′)f_X(t)\, f_Y(t^{\prime})
4
fX(t)fXY(t,t′)\dfrac{f_X(t)}{f_{XY}(t, t^{\prime})}
Solution
Idea

Divide by the marginal of the variable you condition on.

  • We condition on X=tX = t, so we divide by fX(t)f_X(t).
  • Option 2 conditions on YY instead.
  • Answer: option 1.
Q3Die and coins

Numerical Answer Type (NAT).

X∼Uniform{1,…,6}X \sim \text{Uniform}\{1, \dots, 6\} and (Y∣X=t)∼Binomial(t,12)(Y \mid X = t) \sim \text{Binomial}(t, \tfrac{1}{2}). Find P(Y=0∣X=3)P(Y = 0 \mid X = 3).

Solution
Idea

Use the binomial PMF with t = 3.

  • (30)(12)0(12)3=18=0.125\binom{3}{0}(\tfrac{1}{2})^0(\tfrac{1}{2})^3 = \frac{1}{8} = 0.125.
  • Answer: 0.125
Q4Joint from a conditional

Multiple Select Question (MSQ): select all that apply.

In the same die-and-coins setup, choose the correct statements.

1
P(Y=4∣X=3)=0P(Y = 4 \mid X = 3) = 0.
2
fXY(3,1)=116f_{XY}(3, 1) = \frac{1}{16}.
3
fXY(2,2)=124f_{XY}(2, 2) = \frac{1}{24}.
4
fY∣X=3(3)=16f_{Y \mid X = 3}(3) = \frac{1}{6}.
Solution
Idea

Joint = marginal × conditional, with marginal 1/6.

  • Option 1: with 3 coins Y≤3Y \le 3, so it is 0.
  • Option 2: 16⋅(31)(12)3=16⋅38=116\frac{1}{6} \cdot \binom{3}{1}(\tfrac{1}{2})^3 = \frac{1}{6} \cdot \frac{3}{8} = \frac{1}{16}.
  • Option 3: 16⋅(22)(12)2=124\frac{1}{6} \cdot \binom{2}{2}(\tfrac{1}{2})^2 = \frac{1}{24}.
  • Option 4: fY∣X=3(3)=(12)3=18f_{Y \mid X = 3}(3) = (\tfrac{1}{2})^3 = \frac{1}{8}, not 16\frac{1}{6}.
  • Answer: options 1, 2 and 3.
Q5Bayes with PMFs

Numerical Answer Type (NAT).

A bag is chosen at random: bag 1 or bag 2, each with probability 12\frac{1}{2}. The chance of a red ball is 0.2 in bag 1 and 0.6 in bag 2. A red ball is drawn. Find the probability that it came from bag 1.

Solution
Idea

Joint over total.

  • P(red)=0.5⋅0.2+0.5⋅0.6=0.4P(\text{red}) = 0.5 \cdot 0.2 + 0.5 \cdot 0.6 = 0.4.
  • P(bag 1∣red)=0.5⋅0.20.4=0.10.4=0.25P(\text{bag 1} \mid \text{red}) = \frac{0.5 \cdot 0.2}{0.4} = \frac{0.1}{0.4} = 0.25.
  • Answer: 0.25
Revision overview
Given an eventf_{X|A}(t) = P((X = t) ∩ A) / P(A)
Range can shrink
Given a variablef_{Y|X=t}(t′) = f_XY(t, t′) / f_X(t)
A rescaled column of the joint
Key identityf_XY = f_X · f_{Y|X=t}
Joint = marginal × conditional
Conditional PMFWeek 1 · Part 4
Named conditionalsDie then coins: (Y|X=t) ~ Bin(t, ½)
Builds the table without listing outcomes
Poisson thinningN ~ Poisson(λ), fair coin n times
X ~ Poisson(λ/2)
GA answersQ2: 0.25 · Q3: 0.50 · Q4: 0
Q8: 5/7 · Q10: 105/512
Revision: conditional PMFs on one page
Next · Part 5Law of Total Probability with Distributions
05
Part 5

Law of Total Probability with Distributions

When an experiment happens in stages, the distribution of the final quantity is a weighted mixture of the conditional distributions. This is the law of total probability applied to PMFs.

5.1Law of total probability with distributions

If we know the marginal of YY and every conditional (X∣Y=y)(X \mid Y = y), we can rebuild the marginal of XX. This is the law of total probability, written with PMFs:

fX(t)=∑yfY(y)⋅fX∣Y=y(t)f_X(t) = \sum_y f_Y(y) \cdot f_{X \mid Y = y}(t)
Same thing as marginalisation. Since fY(y)fX∣Y=y(t)=fXY(t,y)f_Y(y) f_{X \mid Y = y}(t) = f_{XY}(t, y), this is just fX(t)=∑yfXY(t,y)f_X(t) = \sum_y f_{XY}(t, y), with the joint written as marginal ×\times conditional.

Example: IPL powerplay over

yy012
fY(y)f_Y(y)1316\frac{13}{16}18\frac{1}{8}116\frac{1}{16}
  • (X∣Y=0)∼Uniform{6,…,12}(X \mid Y = 0) \sim \text{Uniform}\{6, \dots, 12\}
  • (X∣Y=1)∼Uniform{2,…,8}(X \mid Y = 1) \sim \text{Uniform}\{2, \dots, 8\}
  • (X∣Y=2)∼Uniform{0,…,6}(X \mid Y = 2) \sim \text{Uniform}\{0, \dots, 6\}

Each conditional has 7 equally likely values, so each conditional PMF equals 17\frac{1}{7} where it applies. Combining with fX(t)=∑fY(y) fX∣Y=y(t)f_X(t) = \sum f_Y(y)\, f_{X \mid Y = y}(t):

  • fX(0)=116⋅17=1112f_X(0) = \frac{1}{16} \cdot \frac{1}{7} = \frac{1}{112} (only Y=2Y = 2 allows 0 runs)
  • fX(2)=18⋅17+116⋅17=3112f_X(2) = \frac{1}{8} \cdot \frac{1}{7} + \frac{1}{16} \cdot \frac{1}{7} = \frac{3}{112} (Y=1Y = 1 and Y=2Y = 2)
  • fX(12)=1316⋅17=13112f_X(12) = \frac{13}{16} \cdot \frac{1}{7} = \frac{13}{112} (only Y=0Y = 0 allows 12 runs)
0123456789101112runs in the over: fX(t)t = runswickets YY = 013/16X|Y=0 ~ U{6…12}Y = 11/8X|Y=1 ~ U{2…8}Y = 21/16X|Y=2 ~ U{0…6}rises towards 6–8 runs, then falls
Figure 15. The mixture rises towards 6–8 runs and then falls
tt0123456789101112
112⋅fX(t)112 \cdot f_X(t)11333316151513131313
Check. The numerators over 112 add up to 1+1+3+3+3+3+16+15+15+13+13+13+13=1121 + 1 + 3 + 3 + 3 + 3 + 16 + 15 + 15 + 13 + 13 + 13 + 13 = 112, so fXf_X is a valid PMF. Plotting fX(t)f_X(t) shows a rise towards t=6t = 6–88 and a fall after: "no-wicket overs" push runs higher.
GA Q5A card, then balls

Draw a card. If it is a face card, draw 2 balls from bag A (4 red, 5 blue, 6 green). If not, draw 3 balls from bag B (8 red, 10 blue, 2 green). YY = number of red balls drawn. Find fY(1)f_Y(1).

Solution
card3/13face card44/1051 red3/13 × 44/10561/105not 1 red10/13not a face card44/951 red10/13 × 44/9551/95not 1 red
Figure 16. Tree: card, then red-ball probability
  • P(Face)=1252=313P(\text{Face}) = \frac{12}{52} = \frac{3}{13}, P(Not face)=1013P(\text{Not face}) = \frac{10}{13}.
  • Bag A (15 balls), exactly 1 red of 2: P(Y=1∣Face)=(41)(111)(152)=44105P(Y = 1 \mid \text{Face}) = \frac{\binom{4}{1}\binom{11}{1}}{\binom{15}{2}} = \frac{44}{105}.
  • Bag B (20 balls), exactly 1 red of 3: P(Y=1∣Not face)=(81)(122)(203)=4495P(Y = 1 \mid \text{Not face}) = \frac{\binom{8}{1}\binom{12}{2}}{\binom{20}{3}} = \frac{44}{95}.
  • fY(1)=44105⋅313+4495⋅1013≈0.4529f_Y(1) = \frac{44}{105} \cdot \frac{3}{13} + \frac{44}{95} \cdot \frac{10}{13} \approx 0.4529. Answer: 0.45
Example 3Rebuild a marginal

Y∼Bernoulli(14)Y \sim \text{Bernoulli}(\frac{1}{4}). (X∣Y=0)∼Uniform{1,2}(X \mid Y = 0) \sim \text{Uniform}\{1, 2\} and (X∣Y=1)∼Uniform{2,3}(X \mid Y = 1) \sim \text{Uniform}\{2, 3\}. Find the PMF of XX.

Solution
  • fX(1)=34⋅12=38f_X(1) = \frac{3}{4} \cdot \frac{1}{2} = \frac{3}{8}.
  • fX(2)=34⋅12+14⋅12=48=12f_X(2) = \frac{3}{4} \cdot \frac{1}{2} + \frac{1}{4} \cdot \frac{1}{2} = \frac{4}{8} = \frac{1}{2}.
  • fX(3)=14⋅12=18f_X(3) = \frac{1}{4} \cdot \frac{1}{2} = \frac{1}{8}.
  • Check: 38+48+18=1\frac{3}{8} + \frac{4}{8} + \frac{1}{8} = 1 ✓.

5.2Going deeper: a PMF as a weighted mixture

  • Picture. fXf_X is a weighted average of the conditional PMFs fX∣Y=yf_{X \mid Y = y}, with weights fY(y)f_Y(y). The weights add up to 1, so the result is again a PMF.
  • Method. Draw a tree: first stage branches with probabilities fY(y)f_Y(y), then for each branch the chance of the value you want. Multiply along each path and add the paths that lead to that value.
  • Support. A value is possible for XX if it is possible under at least one branch. The support of the mixture is the union of the conditional supports.
  • Overlap adds. A value allowed by several branches collects a contribution from each (like fX(2)f_X(2) in the IPL example).
  • Then reverse it. Once you have fX(t)f_X(t), Bayes gives the probability of a branch given the outcome: P(Y=y∣X=t)=fY(y)fX∣Y=y(t)fX(t)P(Y = y \mid X = t) = \frac{f_Y(y) f_{X \mid Y = y}(t)}{f_X(t)}.

5.3Exam tips and common mistakes

Exam tips
  • Draw the tree and label every branch with its probability before computing.
  • Check that the branch weights add up to 1 and that the final PMF adds up to 1.
  • For "which branch did it come from" questions, use the total as the denominator.
Common mistakes
  • Forgetting to multiply by the branch weight, and adding conditional PMFs directly.
  • Leaving out a branch that also allows the value.
  • Using a branch weight that is not a probability (weights must add to 1).

Practice questions (graded-assignment style)

Q1A mixture value

Numerical Answer Type (NAT).

Y∼Bernoulli(13)Y \sim \text{Bernoulli}(\tfrac{1}{3}). (X∣Y=0)∼Uniform{1,2}(X \mid Y = 0) \sim \text{Uniform}\{1, 2\} and (X∣Y=1)∼Uniform{2,3}(X \mid Y = 1) \sim \text{Uniform}\{2, 3\}. Find fX(2)f_X(2).

Solution
Idea

Both branches allow X = 2.

  • P(Y=0)=23P(Y = 0) = \frac{2}{3}, P(Y=1)=13P(Y = 1) = \frac{1}{3}.
  • fX(2)=23⋅12+13⋅12=13+16=12f_X(2) = \frac{2}{3} \cdot \frac{1}{2} + \frac{1}{3} \cdot \frac{1}{2} = \frac{1}{3} + \frac{1}{6} = \frac{1}{2}.
  • Answer: 0.5
Q2Two coins

Numerical Answer Type (NAT).

A fair coin picks coin A (Heads probability 0.9) or coin B (Heads probability 0.3), then the chosen coin is tossed once. Find the probability of Heads.

Solution
Idea

Weight each coin by 1/2.

  • P(H)=0.5⋅0.9+0.5⋅0.3=0.45+0.15=0.6P(\text{H}) = 0.5 \cdot 0.9 + 0.5 \cdot 0.3 = 0.45 + 0.15 = 0.6.
  • Answer: 0.6
Q3Reverse the mixture

Numerical Answer Type (NAT).

In the same two-coin experiment, the toss shows Heads. Find the probability that coin A was chosen.

Solution
Idea

Branch contribution divided by the total.

  • P(A∣H)=0.5⋅0.90.6=0.450.6=0.75P(\text{A} \mid \text{H}) = \frac{0.5 \cdot 0.9}{0.6} = \frac{0.45}{0.6} = 0.75.
  • Answer: 0.75
Q4Facts about mixtures

Multiple Select Question (MSQ): select all that apply.

Choose the correct statements about fX(t)=∑yfY(y) fX∣Y=y(t)f_X(t) = \sum_y f_Y(y)\, f_{X \mid Y = y}(t).

1
The weights fY(y)f_Y(y) add up to 1.
2
A value is possible for XX if it is possible under at least one branch.
3
It is the same as marginalisation of the joint PMF.
4
fXf_X need not add up to 1.
Solution
Idea

It is just marginalisation written with conditionals.

  • Options 1, 2 and 3 are true.
  • Option 4 is false: ∑tfX(t)=∑yfY(y)⋅1=1\sum_t f_X(t) = \sum_y f_Y(y) \cdot 1 = 1.
  • Answer: options 1, 2 and 3.
Revision overview
Formulaf_X(t) = Σ f_Y(y) · f_{X|Y=y}(t)
Marginal rebuilt from conditionals
Why it worksf_Y · f_{X|Y} = f_XY
So it is marginalisation
Total Probability with PMFsWeek 1 · Part 5
IPL overY: 13/16, 1/8, 1/16
Each X|Y uniform on 7 values
f_X(0) = 1/112, f_X(12) = 13/112
GA Q5Face: 44/105 · not face: 44/95
f_Y(1) ≈ 0.4529
Revision: total probability with PMFs on one page
Next · Part 6Many Random Variables: Joint and Marginal PMFs
06
Part 6

Many Random Variables: Joint and Marginal PMFs

Nothing conceptually new happens with three or more variables: the joint PMF has one more argument, and a marginal is still "sum out everything you do not keep".

6.1Joint PMF of more than two random variables

fX1,…,Xn(t1,…,tn)=P(X1=t1 and … and Xn=tn)f_{X_1, \dots, X_n}(t_1, \dots, t_n) = P(X_1 = t_1 \text{ and } \dots \text{ and } X_n = t_n)

The two-variable definition extends directly: nothing conceptually new.

Example: toss a fair coin thrice

All 8 combinations of (t1,t2,t3)(t_1, t_2, t_3) are equally likely, so each cell is 18\frac{1}{8}.

Joint PMF of three fair coins: all 8 combinations equally likely0001/80011/80101/80111/81001/81011/81101/81111/8f(t₁, t₂, t₃) = 1/8 for every cellfX1(0) = 4 × 1/8 = 1/2 (4 rows have t₁ = 0)
Figure 17. Three coins: every combination has probability 1/8

Example: a random 3-digit number 000–999

XX = first digit, YY = number mod 2, ZZ = last digit. fXYZ(0,0,0)f_{XYZ}(0, 0, 0): starts 0, even, ends 0, so {000,010,…,090}\{000, 010, \dots, 090\}: 101000=1100\frac{10}{1000} = \frac{1}{100}. fXYZ(1,0,1)=0f_{XYZ}(1, 0, 1) = 0: a number ending in 1 is always odd, so Y=0Y = 0 is impossible.

fXYZ(t1,t2,t3)={0if the parity of t3 does not match t21100otherwisef_{XYZ}(t_1, t_2, t_3) = \begin{cases} 0 & \text{if the parity of } t_3 \text{ does not match } t_2 \\ \frac{1}{100} & \text{otherwise} \end{cases}
Check. t1t_1 can be any of 10 digits, t3t_3 any of 10 digits, and t2t_2 is then forced by the parity of t3t_3: 10×10=10010 \times 10 = 100 nonzero cells of 1100\frac{1}{100}, which add up to 1.
Why this gets hard fast

For a 6-ball IPL over with runs X1,…,X6∈{0,…,8}X_1, \dots, X_6 \in \{0, \dots, 8\}, a full joint table needs 969^6 entries if every value 0 to 8 is allowed (the source writes 868^6): impossible by hand. Marginalisation and conditioning make it manageable.

6.2Marginal PMF with more than two variables

Same idea as before: sum the joint PMF over every value of all other variables.

fX1(t)=∑t2′,…,tn′fX1,…,Xn(t,t2′,…,tn′)f_{X_1}(t) = \sum_{t_2^{\prime}, \dots, t_n^{\prime}} f_{X_1, \dots, X_n}(t, t_2^{\prime}, \dots, t_n^{\prime})

Example: coin thrice

fX1(0)f_{X_1}(0): 4 rows have t1=0t_1 = 0, each 18\frac{1}{8}, so 4×18=124 \times \frac{1}{8} = \frac{1}{2}. Same for fX1(1)=12f_{X_1}(1) = \frac{1}{2}.

Example: random 3-digit number

Random 3-digit number 000–999: X = first digit, Y = number mod 2, Z = last digitXfirst digitUniform{0…9}Ynumber mod 2Uniform{0, 1}Zlast digitUniform{0…9}fXYZ = 1/100 when the parity of t₃ matches t₂, otherwise 0100 nonzero cells × 1/100 = 1; e.g. f(1,0,1) = 0 since a number ending in 1 is odd
Figure 18. Each marginal is uniform

Any fixed first digit: 100 of 1000 numbers, so fX(x)=110f_X(x) = \frac{1}{10} for each xx and XX is uniform. Y∼Uniform{0,1}Y \sim \text{Uniform}\{0, 1\} (500 even, 500 odd). Z∼Uniform{0,…,9}Z \sim \text{Uniform}\{0, \dots, 9\}.

Example: IPL powerplay, over 1 (real data)

1598 first-overs: ball 1 had 957 dots, 429 singles, 57 twos, 5 threes, 138 fours, 8 fives, 4 sixes. So P(X1=0)=9571598≈0.5989P(X_1 = 0) = \frac{957}{1598} \approx 0.5989, P(X1=1)=4291598≈0.2685P(X_1 = 1) = \frac{429}{1598} \approx 0.2685, P(X1=4)=1381598≈0.0864P(X_1 = 4) = \frac{138}{1598} \approx 0.0864. Doing this for all 6 balls gives a full table of marginals fX1,…,fX6f_{X_1}, \dots, f_{X_6}.

0.59900.26810.03620.00330.08640.00550.0036Ball 1 of the first over: runs X₁1598 first-oversP(X₁ = 0) = 957/1598≈ 0.5989P(X₁ = 1) = 429/1598≈ 0.2685P(X₁ = 4) = 138/1598≈ 0.0864
Figure 19. Marginal PMF of the runs on ball 1 (counts add up to 1598)
Check. 957+429+57+5+138+8+4=1598957 + 429 + 57 + 5 + 138 + 8 + 4 = 1598 ✓. The source also reports that sixes and fours are most likely on ball 4 and dot balls least common on ball 6 ("batters open up as the over wears on"); that comes from the full 6-ball table, which the notes do not print.

6.3Marginalisation with three or more variables

You can also marginalise down to a pair from a joint over three variables: sum over whichever is left out.

fX1X2(t1,t2)=∑t3′fX1X2X3(t1,t2,t3′)f_{X_1 X_2}(t_1, t_2) = \sum_{t_3^{\prime}} f_{X_1 X_2 X_3}(t_1, t_2, t_3^{\prime})

Example: marginalising a 3-variable joint PMF

A 3-variable joint PMF: 9 combinations, each 1/90001/90011/90021/90111/90121/91001/91021/91101/91111/9(t₁, t₂, t₃) written as a three-digit string
Figure 20. Nine combinations of (t₁, t₂, t₃), each 1/9
t1t_1t2t_2t3t_3ff
00019\frac{1}{9}
00119\frac{1}{9}
00219\frac{1}{9}
01119\frac{1}{9}
01219\frac{1}{9}
10019\frac{1}{9}
10219\frac{1}{9}
11019\frac{1}{9}
11119\frac{1}{9}

Sum out t3t_3 to get fX1X2f_{X_1 X_2}, then do the same for the other pairs:

fX1X2fX2X3fX1X3X1X20101/32/912/92/9X2X30102/91/911/92/922/91/9X1X30101/92/912/91/922/91/9Sum out whichever variable is left out: e.g. fX1X2(t₁, t₂) = Σ fX1X2X3(t₁, t₂, t′₃)
Figure 21. The three pairwise marginals of the same joint PMF
Check one. fX1X2(0,0)f_{X_1 X_2}(0, 0): the rows (0,0,0),(0,0,1),(0,0,2)(0, 0, 0), (0, 0, 1), (0, 0, 2) all have t1=t2=0t_1 = t_2 = 0, so 3×19=133 \times \frac{1}{9} = \frac{1}{3} ✓. Every pair table adds up to 1.

6.4The general marginal PMF formula

General formula
fXi1,…,Xik(ti1,…,tik)=∑fX1,…,Xn(t1,…,tn)f_{X_{i_1}, \dots, X_{i_k}}(t_{i_1}, \dots, t_{i_k}) = \sum f_{X_1, \dots, X_n}(t_1, \dots, t_n)

summed over every tjt_j not in the kept set.

That is all there is to it

Pick the variables you want; sum out everything else.

Example 4Marginalise a three-variable PMF

Three fair coins give X1,X2,X3X_1, X_2, X_3. Find fX1X3f_{X_1 X_3} and say whether X1X_1 and X3X_3 are independent.

Solution
  • fX1X3(a,c)=∑t218=28=14f_{X_1 X_3}(a, c) = \sum_{t_2} \frac{1}{8} = \frac{2}{8} = \frac{1}{4} for each of the four pairs (a,c)(a, c).
  • fX1(a)fX3(c)=12⋅12=14f_{X_1}(a) f_{X_3}(c) = \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{4}, equal in every cell, so independent.

6.5Going deeper: tables with three or more variables

  • Size. If each of nn variables takes mm values, the joint table has mnm^n cells. Three variables on {0,1,2}\{0, 1, 2\} give 2727 cells; a 6-ball over gives 969^6, far too many to write down.
  • Marginals step by step. To keep (X1,X2)(X_1, X_2) from a 3-variable joint, sum out t3t_3. To keep only X1X_1, sum out t2t_2 and t3t_3. Summing in stages gives the same answer as summing all at once.
  • Pairwise is not mutual (a classic). Let X1,X2X_1, X_2 be independent fair bits and X3=X1⊕X2X_3 = X_1 \oplus X_2 (their sum mod 2). Each pair is independent, but f(0,0,1)=0≠18f(0, 0, 1) = 0 \neq \frac{1}{8}, so the three are not mutually independent.
  • Support counting. Count the nonzero cells before assigning probabilities. Here there are 4 nonzero cells of 14\frac{1}{4} each, out of 8.
  • Which variables are kept? Always list them first: the formula sums over all the others.

6.6Exam tips and common mistakes

Exam tips
  • Write down which variables you keep and which you sum out.
  • Check each pairwise table adds up to 1.
  • For independence of three variables, test f(t1,t2,t3)=f(t1)f(t2)f(t3)f(t_1, t_2, t_3) = f(t_1) f(t_2) f(t_3) in every cell.
Common mistakes
  • Summing over the kept variable instead of the others.
  • Assuming pairwise independence implies mutual independence.
  • Miscounting cells (mnm^n, not m⋅nm \cdot n).

Practice questions (graded-assignment style)

Q1Cells in a table

Numerical Answer Type (NAT).

Each of three random variables takes values in {0,1,2}\{0, 1, 2\}. How many cells does the joint table have?

Solution
Idea

Multiply the number of values.

  • 3×3×3=273 \times 3 \times 3 = 27.
  • Answer: 27
Q2Nonzero cells

Numerical Answer Type (NAT).

X1,X2X_1, X_2 are independent fair bits and X3X_3 is their sum mod 2 (X3=1X_3 = 1 exactly when X1≠X2X_1 \neq X_2). How many of the 8 cells of the joint PMF are nonzero?

Solution
Idea

X3X_3 is fixed by X1,X2X_1, X_2.

  • (X1,X2)(X_1, X_2) has 4 equally likely values, and each fixes X3X_3.
  • So 4 cells are nonzero, each 14\frac{1}{4}.
  • Answer: 4
Q3Pairwise or mutual?

Multiple Select Question (MSQ): select all that apply.

For the same X1,X2,X3X_1, X_2, X_3, choose the correct statements.

1
X1X_1 and X2X_2 are independent.
2
X1X_1 and X3X_3 are independent.
3
The three are mutually independent.
4
fX3(1)=12f_{X_3}(1) = \frac{1}{2}.
Solution
Idea

Compare pairs, then compare the full product.

  • Option 1: given in the setup.
  • Option 2: P(X1=a,X3=c)=14=12⋅12P(X_1 = a, X_3 = c) = \frac{1}{4} = \frac{1}{2} \cdot \frac{1}{2} for all a,ca, c.
  • Option 3 is false: f(0,0,1)=0f(0, 0, 1) = 0 but 12⋅12⋅12=18\frac{1}{2} \cdot \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{8}.
  • Option 4: X3=1X_3 = 1 when (0,1)(0, 1) or (1,0)(1, 0), so 12\frac{1}{2}.
  • Answer: options 1, 2 and 4.
Q4Marginal from three variables

Numerical Answer Type (NAT).

The 9 equally likely rows (t1,t2,t3)(t_1, t_2, t_3) are (0,0,0),(0,0,1),(0,0,2),(0,1,1),(0,1,2),(1,0,0),(1,0,2),(1,1,0),(1,1,1)(0,0,0), (0,0,1), (0,0,2), (0,1,1), (0,1,2), (1,0,0), (1,0,2), (1,1,0), (1,1,1). Find fX1X2(0,1)f_{X_1 X_2}(0, 1).

Solution
Idea

Count the rows with t1=0t_1 = 0 and t2=1t_2 = 1, then divide by 9.

  • Rows (0,1,1)(0, 1, 1) and (0,1,2)(0, 1, 2) match.
  • fX1X2(0,1)=29≈0.22f_{X_1 X_2}(0, 1) = \frac{2}{9} \approx 0.22.
  • Answer: 0.22
Revision overview
Joint PMFf(t₁, …, tₙ) = P(X₁ = t₁, …, Xₙ = tₙ)
Nothing conceptually new
ExamplesCoin thrice: each cell 1/8
3-digit number: 1/100 or 0
Hard fast6-ball over: ~9⁶ cells
Use marginals and conditionals
More than Two VariablesWeek 1 · Part 6
MarginalSum over all other variables
f_X₁(t) = Σ f(t, t₂′, …, tₙ′)
To a pairf_X₁X₂ = Σ over t₃′ of f_X₁X₂X₃
Any subset works
IPL real dataBall 1: 957/1598 ≈ 0.5989 dots
Marginals f_X₁ … f_X₆
Revision: joint and marginal PMFs for many variables on one page
Next · Part 7Conditioning with Multiple Random Variables
07
Part 7

Conditioning with Multiple Random Variables

The same "joint ÷ what you condition on" recipe works however many variables are involved. The only new thing is bookkeeping.

7.1Conditioning with several variables

(X₁ | X₂ = t₂)→fX1X2(t₁, t₂) / fX2(t₂)(X₁, X₂ | X₃ = t₃)→fX1X2X3(t₁, t₂, t₃) / fX3(t₃)(X₁ | X₂ = t₂, X₃ = t₃)→fX1X2X3(t₁, t₂, t₃) / fX2X3(t₂, t₃)Recipe: joint of everything ÷ (marginal or joint) of what you condition on
Figure 22. Three common conditioning patterns
Recipe

Joint of everything ÷\div (marginal or joint) of what you condition on.

Example: conditioning with four variables

12 equally likely (112\frac{1}{12} each) rows of (X1,X2,X3,X4)(X_1, X_2, X_3, X_4):

t1t_1t2t_2t3t_3t4t_4
0000
0001
0011
0020
0110
0111
0120
1001
1020
1021
1101
1110
  • (a) (X1∣X2=0)(X_1 \mid X_2 = 0): 7 rows have t2=0t_2 = 0, so P(X2=0)=712P(X_2 = 0) = \frac{7}{12}; of these, 4 have t1=0t_1 = 0 and 3 have t1=1t_1 = 1. P(X1=0∣X2=0)=47P(X_1 = 0 \mid X_2 = 0) = \frac{4}{7}, P(X1=1∣X2=0)=37P(X_1 = 1 \mid X_2 = 0) = \frac{3}{7}.
  • (b) (X1∣X3=0,X4=1)(X_1 \mid X_3 = 0, X_4 = 1): 3 rows match (t3,t4)=(0,1)(t_3, t_4) = (0, 1); 1 has t1=0t_1 = 0 and 2 have t1=1t_1 = 1. P(X1=0∣X3=0,X4=1)=13P(X_1 = 0 \mid X_3 = 0, X_4 = 1) = \frac{1}{3}, P(X1=1∣⋅)=23P(X_1 = 1 \mid \cdot) = \frac{2}{3}.
  • (c) (X3,X4∣X1=0)(X_3, X_4 \mid X_1 = 0): 7 rows have t1=0t_1 = 0, so P(X1=0)=712P(X_1 = 0) = \frac{7}{12}; tally each (t3,t4)(t_3, t_4) among those 7:
(X₃, X₄ | X₁ = 0): tally the 7 rows with t₁ = 0X3X401201/71/72/711/72/70P(X₁ = 0) = 7/12each (t₃, t₄) count ÷ 7
Figure 23. A conditional joint PMF: the 7 rows with t₁ = 0, each (t₃, t₄) counted
The step to remember. Conditioning is just filtering the rows and recounting. After filtering, the remaining rows are equally likely again, so each conditional probability is a simple count ratio.
GA Q6Which identity is always true?

Which is always correct? (1) fXYZ=fX∣Y,Z⋅fYZf_{XYZ} = f_{X \mid Y, Z} \cdot f_{YZ}; (2) fXYZ=fX∣Y,Z⋅fY∣X⋅fXf_{XYZ} = f_{X \mid Y, Z} \cdot f_{Y \mid X} \cdot f_X; (3) fX(x)=∑xfXY(x,y)f_X(x) = \sum_x f_{XY}(x, y); (4) fXY=fX⋅fYf_{XY} = f_X \cdot f_Y.

Solution
  • (1): this is the conditioning definition rearranged. Always true.
  • (2): mixes the conditioning variables incorrectly. False. (The correct chain would be fX∣Y,Z⋅fY∣Z⋅fZf_{X \mid Y, Z} \cdot f_{Y \mid Z} \cdot f_Z, or fZ∣X,Y⋅fY∣X⋅fXf_{Z \mid X, Y} \cdot f_{Y \mid X} \cdot f_X.)
  • (3): sums over the wrong variable (it should sum over yy, not xx). False.
  • (4): holds only if X,YX, Y are independent. Not general. False.
  • Answer: Option 1

7.2Going deeper: conditioning on several variables

  • One recipe for every pattern. Conditional = joint of everything that appears ÷\div joint (or marginal) of what is given. For example fX∣Y,Z=fXYZfYZf_{X \mid Y, Z} = \frac{f_{XYZ}}{f_{YZ}} and fXY∣Z=fXYZfZf_{XY \mid Z} = \frac{f_{XYZ}}{f_Z}.
  • Filter, then count. If the original rows are equally likely, conditioning means keeping the rows that match the given values; the survivors are still equally likely, so each conditional probability is a count ratio.
  • Identities that are always true. fXYZ=fX∣Y,Z fYZ=fX∣Y,Z fY∣Z fZf_{XYZ} = f_{X \mid Y, Z}\, f_{YZ} = f_{X \mid Y, Z}\, f_{Y \mid Z}\, f_Z. Each factor conditions on everything after it in the chain.
  • Identities that need independence. fXY=fXfYf_{XY} = f_X f_Y holds only when X,YX, Y are independent.
  • More given values shrink the range. The more you condition on, the fewer rows survive, so the conditional range can only get smaller.

7.3Exam tips and common mistakes

Exam tips
  • Match the denominator to exactly the variables that appear after the bar.
  • Count rows after filtering; do not reuse the original denominator.
  • To test a claimed identity, ask whether it is just the definition of conditional probability rearranged.
Common mistakes
  • Dividing by the joint of everything instead of the joint of the given variables.
  • Writing a factor that does not condition on all the variables that come after it.
  • Using fXY=fXfYf_{XY} = f_X f_Y without independence.

Practice questions (graded-assignment style)

Q1Condition on one variable

Numerical Answer Type (NAT).

Six equally likely rows of (X1,X2,X3)(X_1, X_2, X_3): (0,0,0),(0,0,1),(0,1,1),(1,0,0),(1,1,0),(1,1,1)(0,0,0), (0,0,1), (0,1,1), (1,0,0), (1,1,0), (1,1,1). Find P(X1=0∣X3=1)P(X_1 = 0 \mid X_3 = 1).

Solution
Idea

Filter the rows with X3=1X_3 = 1.

  • Rows with X3=1X_3 = 1: (0,0,1),(0,1,1),(1,1,1)(0,0,1), (0,1,1), (1,1,1), that is 3 rows.
  • Two of them have X1=0X_1 = 0, so the probability is 23≈0.67\frac{2}{3} \approx 0.67.
  • Answer: 0.67
Q2A conditional joint

Numerical Answer Type (NAT).

In the same six rows, find P(X1=1,X2=1∣X3=0)P(X_1 = 1, X_2 = 1 \mid X_3 = 0).

Solution
Idea

Filter the rows with X3=0X_3 = 0.

  • Rows with X3=0X_3 = 0: (0,0,0),(1,0,0),(1,1,0)(0,0,0), (1,0,0), (1,1,0), 3 rows.
  • Only (1,1,0)(1, 1, 0) has X1=X2=1X_1 = X_2 = 1, so the probability is 13≈0.33\frac{1}{3} \approx 0.33.
  • Answer: 0.33
Q3Always true

Multiple Choice Question (MCQ): choose the one correct option.

Which identity is always true?

1
fXYZ=fX∣Y,Z fY∣Z fZf_{XYZ} = f_{X \mid Y, Z}\, f_{Y \mid Z}\, f_Z
2
fXYZ=fX∣Y,Z fY fZf_{XYZ} = f_{X \mid Y, Z}\, f_Y\, f_Z
3
fX∣Y,Z=fXYZfZf_{X \mid Y, Z} = \dfrac{f_{XYZ}}{f_Z}
4
fXY=fX fYf_{XY} = f_X\, f_Y
Solution
Idea

Each factor conditions on everything after it.

  • Option 1 is the chain rule.
  • Option 2 drops the conditioning of YY on ZZ (true only with independence).
  • Option 3 should divide by fYZf_{YZ}.
  • Option 4 needs independence.
  • Answer: option 1.
Q4Facts about conditioning

Multiple Select Question (MSQ): select all that apply.

Choose the correct statements.

1
A conditional PMF adds up to 1 over the free variable.
2
The range of (X∣A)(X \mid A) can be smaller than the range of XX.
3
Conditioning on a probability-0 value is well defined.
4
If the rows are equally likely, the rows that survive filtering are equally likely.
Solution
Idea

Conditioning is filtering and rescaling.

  • Options 1, 2 and 4 are true.
  • Option 3 is false: the formula divides by 0.
  • Answer: options 1, 2 and 4.
Revision overview
RecipeJoint of everything
÷ (marginal or joint) of the conditioning variables
Patterns(X₁|X₂ = t₂)
(X₁, X₂|X₃ = t₃)
(X₁|X₂ = t₂, X₃ = t₃)
Conditioning with Several VariablesWeek 1 · Part 7
Four-variable exampleFilter the rows, recount
(a) 4/7, 3/7 · (b) 1/3, 2/3
(c) a 2 × 3 table over 7 rows
GA Q6f_XYZ = f_{X|Y,Z} · f_YZ is always true
f_XY = f_X f_Y only if independent
Revision: conditioning with several variables on one page
Next · Part 8Factoring the Joint PMF
08
Part 8

Factoring the Joint PMF

A joint PMF over many variables can be written as a product of one marginal and a chain of conditionals, in any order. This is how big joint distributions are built from small, simple pieces.

8.1Factoring the joint PMF

A complicated joint PMF can be factored into simpler conditional and marginal pieces, like factoring a number into smaller parts.

fX1X2X3X4=fX1∣X2,X3,X4⋅fX2∣X3,X4⋅fX3∣X4⋅fX4f_{X_1 X_2 X_3 X_4} = f_{X_1 \mid X_2, X_3, X_4} \cdot f_{X_2 \mid X_3, X_4} \cdot f_{X_3 \mid X_4} \cdot f_{X_4}
Why it works. Each step is "joint = conditional ×\times marginal" applied to what is left: fX1…X4=fX1∣X2X3X4⋅fX2X3X4f_{X_1 \dots X_4} = f_{X_1 \mid X_2 X_3 X_4} \cdot f_{X_2 X_3 X_4}, then fX2X3X4=fX2∣X3X4⋅fX3X4f_{X_2 X_3 X_4} = f_{X_2 \mid X_3 X_4} \cdot f_{X_3 X_4}, and so on. This is the chain rule of probability for random variables.
JointfXY(x, y)MarginalfX(x), fY(y)ConditionalfY|X=x(y)sum out÷ marginalmarginal × conditional= back to the joint
Figure 24. Joint, marginal and conditional PMFs, and how to move between them

Example: factoring a 3-variable joint PMF

Using the earlier 9-row table: fX1X2X3=fX3⋅fX2∣X3⋅fX1∣X2,X3f_{X_1 X_2 X_3} = f_{X_3} \cdot f_{X_2 \mid X_3} \cdot f_{X_1 \mid X_2, X_3}. At (0,0,0)(0, 0, 0): fX3(0)=39f_{X_3}(0) = \frac{3}{9}, fX2∣X3=0(0)=23f_{X_2 \mid X_3 = 0}(0) = \frac{2}{3}, fX1∣X2=0,X3=0(0)=12f_{X_1 \mid X_2 = 0, X_3 = 0}(0) = \frac{1}{2}, and 39⋅23⋅12=19\frac{3}{9} \cdot \frac{2}{3} \cdot \frac{1}{2} = \frac{1}{9} ✓ matches the table.

Order doesn't matter

You can peel off the variables in any sequence and still get a valid factorisation:

fX1X2X3X4=fX4∣X3,X2,X1⋅fX3∣X2,X1⋅fX2∣X1⋅fX1f_{X_1 X_2 X_3 X_4} = f_{X_4 \mid X_3, X_2, X_1} \cdot f_{X_3 \mid X_2, X_1} \cdot f_{X_2 \mid X_1} \cdot f_{X_1}
fX1X2X3X4=fX3∣X2,X1,X4⋅fX2∣X1,X4⋅fX1∣X4⋅fX4f_{X_1 X_2 X_3 X_4} = f_{X_3 \mid X_2, X_1, X_4} \cdot f_{X_2 \mid X_1, X_4} \cdot f_{X_1 \mid X_4} \cdot f_{X_4}

Example: the same PMF, factored a different way

fX1X2X3=fX1⋅fX2∣X1⋅fX3∣X1,X2f_{X_1 X_2 X_3} = f_{X_1} \cdot f_{X_2 \mid X_1} \cdot f_{X_3 \mid X_1, X_2}. At (0,0,0)(0, 0, 0): fX1(0)=59f_{X_1}(0) = \frac{5}{9}, fX2∣X1=0(0)=35f_{X_2 \mid X_1 = 0}(0) = \frac{3}{5}, fX3∣X1=0,X2=0(0)=13f_{X_3 \mid X_1 = 0, X_2 = 0}(0) = \frac{1}{3}, and 59⋅35⋅13=19\frac{5}{9} \cdot \frac{3}{5} \cdot \frac{1}{3} = \frac{1}{9} ✓: same answer, different route.

fX1X2X3 = fX3 · fX2|X3 · fX1|X2,X3peel the variables off one at a time, in any orderRoute 1 at (0,0,0)fX3(0) = 3/9×fX2|X3=0(0) = 2/3×fX1|X2=0,X3=0(0) = 1/2Route 2 at (0,0,0)fX1(0) = 5/9×fX2|X1=0(0) = 3/5×fX3|X1=0,X2=0(0) = 1/3(3/9)(2/3)(1/2) = 1/9 = (5/9)(3/5)(1/3) ✓ matches the table
Figure 25. Two factorisations of the same cell give the same 1/9
Why bother? When the dependence has a simple structure, the conditional pieces are small and familiar (for example (Y∣X=t)∼Binomial(t,12)(Y \mid X = t) \sim \text{Binomial}(t, \tfrac{1}{2})), so the huge joint table never has to be written out.
Example 5Factor and multiply back

Use the 9-row table to compute fX1X2X3(1,1,1)f_{X_1 X_2 X_3}(1, 1, 1) as fX3(1)⋅fX2∣X3=1(1)⋅fX1∣X2=1,X3=1(1)f_{X_3}(1) \cdot f_{X_2 \mid X_3 = 1}(1) \cdot f_{X_1 \mid X_2 = 1, X_3 = 1}(1) and check it against 19\frac{1}{9}.

Solution
  • Rows with t3=1t_3 = 1: (0,0,1),(0,1,1),(1,1,1)(0,0,1), (0,1,1), (1,1,1): fX3(1)=39f_{X_3}(1) = \frac{3}{9}.
  • Among them t2=1t_2 = 1: (0,1,1),(1,1,1)(0,1,1), (1,1,1): fX2∣X3=1(1)=23f_{X_2 \mid X_3 = 1}(1) = \frac{2}{3}.
  • Among those t1=1t_1 = 1: only (1,1,1)(1,1,1): fX1∣X2=1,X3=1(1)=12f_{X_1 \mid X_2 = 1, X_3 = 1}(1) = \frac{1}{2}.
  • Product: 39⋅23⋅12=19\frac{3}{9} \cdot \frac{2}{3} \cdot \frac{1}{2} = \frac{1}{9} ✓.

8.2Going deeper: the chain rule as a calculation tool

  • Idea. Peel one variable at a time: fX1X2X3=fX1 fX2∣X1 fX3∣X1,X2f_{X_1 X_2 X_3} = f_{X_1}\, f_{X_2 \mid X_1}\, f_{X_3 \mid X_1, X_2}. Each factor conditions on all earlier variables.
  • Any order works. There are n!n! orders for nn variables (6 for three variables). Choose the order whose factors are easiest to compute.
  • Sequential draws. Drawing without replacement is naturally a chain. From 3 red and 2 blue, P(red, red)=35⋅24=310P(\text{red, red}) = \frac{3}{5} \cdot \frac{2}{4} = \frac{3}{10}: the second factor conditions on the first draw.
  • Named pieces. If the conditionals are familiar distributions (Uniform, Binomial, Poisson), the factorisation builds the joint without ever listing the table.
  • Checking. Multiply the factors for one cell and compare with the table entry. Two different orders must give the same number.

8.3Exam tips and common mistakes

Exam tips
  • Start from one marginal, then multiply conditionals that each condition on all earlier variables.
  • For draws without replacement, update the counts after each draw.
  • Verify one cell with two different orders if time permits.
Common mistakes
  • Dropping a variable from the conditioning part of a factor.
  • Using the plain marginals fX1fX2fX3f_{X_1} f_{X_2} f_{X_3} when the variables are not independent.
  • Forgetting the last factor is a marginal, not a conditional.

Practice questions (graded-assignment style)

Q1Two draws

Numerical Answer Type (NAT).

A bag has 3 red and 2 blue balls. Two are drawn without replacement. Find P(both red)P(\text{both red}).

Solution
Idea

Chain rule: first draw, then second given the first.

  • P(1st red)=35P(\text{1st red}) = \frac{3}{5}.
  • P(2nd red∣1st red)=24P(\text{2nd red} \mid \text{1st red}) = \frac{2}{4}.
  • Product: 35⋅24=620=0.3\frac{3}{5} \cdot \frac{2}{4} = \frac{6}{20} = 0.3.
  • Answer: 0.3
Q2Three draws in order

Numerical Answer Type (NAT).

From the same bag (3 red, 2 blue) three balls are drawn without replacement. Find the probability of the order red, blue, red.

Solution
Idea

Update the counts after every draw.

  • 1st red: 35\frac{3}{5}. Left: 2 red, 2 blue.
  • 2nd blue: 24\frac{2}{4}. Left: 2 red, 1 blue.
  • 3rd red: 23\frac{2}{3}.
  • Product: 35⋅24⋅23=1260=0.2\frac{3}{5} \cdot \frac{2}{4} \cdot \frac{2}{3} = \frac{12}{60} = 0.2.
  • Answer: 0.2
Q3Number of orders

Multiple Choice Question (MCQ): choose the one correct option.

In how many different orders can fX1X2X3f_{X_1 X_2 X_3} be factored using the chain rule?

1
3
2
6
3
9
4
1
Solution
Idea

Count the orderings of three variables.

  • 3!=3×2×1=63! = 3 \times 2 \times 1 = 6.
  • Answer: option 2.
Q4Valid factorisations

Multiple Select Question (MSQ): select all that apply.

Which are valid factorisations of fX1X2X3f_{X_1 X_2 X_3} in general?

1
fX1 fX2∣X1 fX3∣X1,X2f_{X_1}\, f_{X_2 \mid X_1}\, f_{X_3 \mid X_1, X_2}
2
fX3 fX2∣X3 fX1∣X2,X3f_{X_3}\, f_{X_2 \mid X_3}\, f_{X_1 \mid X_2, X_3}
3
fX1 fX2 fX3f_{X_1}\, f_{X_2}\, f_{X_3}
4
fX1∣X2,X3 fX2∣X3 fX3f_{X_1 \mid X_2, X_3}\, f_{X_2 \mid X_3}\, f_{X_3}
Solution
Idea

Each factor must condition on all variables that come after (or before) it in the chain.

  • Options 1, 2 and 4 are chain-rule orders.
  • Option 3 is valid only when the three variables are independent.
  • Answer: options 1, 2 and 4.
Revision overview
Chain rulef_X₁X₂X₃X₄ = f_{X₁|X₂X₃X₄} · f_{X₂|X₃X₄} · f_{X₃|X₄} · f_X₄
IdeaJoint → conditional × marginal
repeated on what is left
Factoring the JointWeek 1 · Part 8
Order is freePeel variables in any sequence
Always a valid factorisation
Check(3/9)(2/3)(1/2) = 1/9
(5/9)(3/5)(1/3) = 1/9
Two routes, same cell
Revision: factoring the joint on one page
Next · PracticeExtra Practice Problems
09
Practice

Extra Practice Problems

Six more problems that pull the whole week together: conditionals from named distributions, joint tables, a function of two variables, drawing without replacement, Bayes with a binomial, and Poisson splitting.

Work through these on your own; each solution is hidden behind a button.

P1Which statement is wrong?

X∼Uniform{1,…,6}X \sim \text{Uniform}\{1, \dots, 6\}; YY = number of times a 2 shows in XX throws of a die. One statement is wrong. Which? (a) P(Y=2∣X=2)=16P(Y = 2 \mid X = 2) = \frac{1}{6} (b) P(Y=2∣X=4)=5263P(Y = 2 \mid X = 4) = \frac{5^2}{6^3} (c) P(Y=5∣X=6)=565P(Y = 5 \mid X = 6) = \frac{5}{6^5} (d) P(Y=6∣X=5)=566P(Y = 6 \mid X = 5) = \frac{5}{6^6}

Solution
  • (Y∣X=t)∼Binomial(t,16)(Y \mid X = t) \sim \text{Binomial}(t, \tfrac{1}{6}), so YY can never exceed XX.
  • (d) claims P(Y=6∣X=5)=566P(Y = 6 \mid X = 5) = \frac{5}{6^6}, but with only 5 throws Y=6Y = 6 is impossible: the true value is 00.
  • (b): (42)(16)2(56)2=6⋅2564=25216=5263\binom{4}{2}(\tfrac{1}{6})^2(\tfrac{5}{6})^2 = \frac{6 \cdot 25}{6^4} = \frac{25}{216} = \frac{5^2}{6^3} ✓. (c): (65)(16)5(56)=6⋅566=565\binom{6}{5}(\tfrac{1}{6})^5(\tfrac{5}{6}) = \frac{6 \cdot 5}{6^6} = \frac{5}{6^5} ✓.
  • Answer: (d)
Look at (a) too. P(Y=2∣X=2)=(16)2=136P(Y = 2 \mid X = 2) = (\tfrac{1}{6})^2 = \frac{1}{36}, not 16\frac{1}{6}, so (a) as printed is also false. The intended odd-one-out is (d), because it is impossible rather than merely mis-computed. If this appears on an exam, choose (d).
P2A joint PMF with a formula

X,Y∈{1,2,3}X, Y \in \{1, 2, 3\}, P(X=i,Y=j)=i+2jcP(X = i, Y = j) = \frac{i + 2j}{c}. Find P(1≤X≤3,  1<Y≤3)P(1 \le X \le 3,\; 1 < Y \le 3).

Solution
  • Find cc: ∑(i+2j)\sum (i + 2j) over all 9 pairs =54= 54, so c=54c = 54.
  • Required region (Y∈{2,3}Y \in \{2, 3\}): ∑(i+2j)\sum (i + 2j) over those 6 pairs =42= 42.
  • P=4254=79P = \frac{42}{54} = \frac{7}{9}. Answer: 7/9
P3A function of two variables

Joint PMF of X,Y∈{1,2,3}X, Y \in \{1, 2, 3\} is given below (kk unknown). Z=X2YZ = X^2 Y. Find the range of (Z∣Y=2)(Z \mid Y = 2) and P(Z=18∣Y=2)P(Z = 18 \mid Y = 2).

Y\XY \backslash X123
1kkkk2k2k
22k2k04k4k
33k3kkk6k6k

Solution
  • Find kk: the coefficients sum to 2020, so k=120k = \frac{1}{20}.
  • Row Y=2Y = 2 has nonzero probability only at X=1X = 1 (2k2k) and X=3X = 3 (4k4k); X=2X = 2 is excluded.
  • Z=X2⋅2Z = X^2 \cdot 2: Z=2Z = 2 (from X=1X = 1) or Z=18Z = 18 (from X=3X = 3).
  • Range (Z∣Y=2)={2,18}(Z \mid Y = 2) = \{2, 18\}; P(Z=18∣Y=2)=4k6k=23P(Z = 18 \mid Y = 2) = \frac{4k}{6k} = \frac{2}{3}. Answer: range {2,18}\{2, 18\}; P=23P = \frac{2}{3}
P4Drawing from a sack

A sack has 3 mangoes, 2 kiwis and 3 guavas. Draw 4 at random. XX = number of mangoes, YY = number of kiwis. Find the joint distribution of X,YX, Y.

Solution
  • Total samples: (84)=70\binom{8}{4} = 70.
  • For each (X,Y)(X, Y): ways =(3X)(2Y)(34−X−Y)= \binom{3}{X}\binom{2}{Y}\binom{3}{4 - X - Y}, valid when 0≤4−X−Y≤30 \le 4 - X - Y \le 3.
Draw 4: X = mangoes, Y = kiwisXY0123003/709/703/7011/709/709/701/7023/709/703/7003/704/703/701/703/703/701/701fYfX
Figure 26. Joint PMF of mangoes and kiwis

Answer: the table above (all over 70). All twelve entries add up to 70/70 = 1.

P5Heads or tails, then 5s

Flip a coin: Heads →\to roll a die 50 times, Tails →\to 51 times. YY = total number of 5s. Find P(X=1∣Y=10)P(X = 1 \mid Y = 10), where X=1X = 1 for Heads.

Solution
Flip a coin: Heads → 50 die rolls, Tails → 51 rolls. Y = number of 5sX = 1 (Heads), P = 1/2(Y | X=1) ~ Bin(50, 1/6)X = 0 (Tails), P = 1/2(Y | X=0) ~ Bin(51, 1/6)P(X=1 | Y=10) = 1 / (1 + (51/41)(5/6)) = 246/501 = 82/167Bayes: the (1/6)¹⁰ and 1/2 factors cancel; C(51,10)/C(50,10) = 51/41
Figure 27. Bayes with two binomials
  • (Y∣X=1)∼Binomial(50,16)(Y \mid X = 1) \sim \text{Binomial}(50, \tfrac{1}{6}), (Y∣X=0)∼Binomial(51,16)(Y \mid X = 0) \sim \text{Binomial}(51, \tfrac{1}{6}), P(X=1)=P(X=0)=12P(X = 1) = P(X = 0) = \frac{1}{2}.
  • Bayes: the (16)10(\tfrac{1}{6})^{10} and 12\frac{1}{2} factors cancel from top and bottom, leaving (5010)(56)40\binom{50}{10}(\tfrac{5}{6})^{40} against (5110)(56)41\binom{51}{10}(\tfrac{5}{6})^{41}, and (5110)/(5010)=5141\binom{51}{10} / \binom{50}{10} = \frac{51}{41}.
  • P(X=1∣Y=10)=11+5141⋅56=246501=82167P(X = 1 \mid Y = 10) = \frac{1}{1 + \frac{51}{41} \cdot \frac{5}{6}} = \frac{246}{501} = \frac{82}{167}. Answer: 82/167
P6Visitors to a yoga academy

Visitors to a yoga academy each day: Poisson(mean 30)\text{Poisson}(\text{mean } 30). Each visitor is a girl or a boy independently, 50/50. Find P(10 boys and 15 girls)P(10 \text{ boys and } 15 \text{ girls}) on a given day.

Solution
Visitors per dayPoisson(30)each: girl or boy, 50/50girls GPoisson(15)boys BPoisson(15)independentP(B=10, G=15) = e⁻¹⁵·15¹⁰/10! · e⁻¹⁵·15¹⁵/15! = e⁻³⁰·15²⁵ / (15!·10!)
Figure 28. Poisson splitting
  • Poisson splitting: the boy-count BB and girl-count GG are independent Poisson, each with mean 30×0.5=1530 \times 0.5 = 15.
  • P(B=10,G=15)=e−15151010!⋅e−15151515!=e−30 152515!  10!P(B = 10, G = 15) = \frac{e^{-15}15^{10}}{10!} \cdot \frac{e^{-15}15^{15}}{15!} = \frac{e^{-30}\, 15^{25}}{15!\; 10!}. Answer: e−30 152515! 10!\dfrac{e^{-30}\, 15^{25}}{15!\, 10!}
Why independent? Compare with the Poisson thinning example of Part 4: there only the Heads were kept, giving Poisson(λ/2)\text{Poisson}(\lambda/2). Here both outcomes are kept, and the two counts turn out to be independent Poisson variables. Verify: P(B=b,G=g)=e−3030b+g(b+g)!(b+gb)(12)b+g=e−1515bb!⋅e−1515gg!P(B = b, G = g) = \frac{e^{-30}30^{b+g}}{(b+g)!}\binom{b+g}{b}(\tfrac{1}{2})^{b+g} = \frac{e^{-15}15^b}{b!} \cdot \frac{e^{-15}15^g}{g!}, a product.
Next · All partsWeek 1 Summary Sheet
10
All parts

Week 1 Summary Sheet

Everything from Week 1 on one sheet, for a last-minute revision.

The four objects

Joint
  • fXY(t1,t2)=P(X=t1,Y=t2)f_{XY}(t_1, t_2) = P(X = t_1, Y = t_2)
  • Entries in [0,1][0, 1], sum to 1
  • Many variables: one more argument
Marginal
  • fX(t)=∑t′fXY(t,t′)f_X(t) = \sum_{t^{\prime}} f_{XY}(t, t^{\prime})
  • Sum out everything you do not keep
  • Joint →\to marginal unique; the reverse is not
Conditional
  • fY∣X=t(t′)=fXY(t,t′)fX(t)f_{Y \mid X = t}(t^{\prime}) = \frac{f_{XY}(t, t^{\prime})}{f_X(t)}
  • Given an event: P((X=t)∩A)P(A)\frac{P((X = t) \cap A)}{P(A)}
  • A rescaled column of the joint
Linking them
  • Joint == marginal ×\times conditional
  • fX(t)=∑yfY(y)fX∣Y=y(t)f_X(t) = \sum_y f_Y(y) f_{X \mid Y = y}(t)
  • Chain rule: peel in any order

Independence and checks

QuestionMethod
Are X and Y independent?fXY=fXfYf_{XY} = f_X f_Y in every cell (one failure is enough)
Is it a valid PMF?entries in [0, 1] and sum to 1 (find unknown constants from the sum)
P(region)add the cells in the region
conditional given a valuepick that row/column, divide by its total
conditioning on a probability-0 valueundefined (the formula divides by 0); GA convention gives 0

Named results from this week

SetupResult
Die, then X fair coinsfXY=16(tt′)(12)tf_{XY} = \frac{1}{6}\binom{t}{t^{\prime}}(\frac{1}{2})^t
N∼Poisson(λ)N \sim \text{Poisson}(\lambda), fair coin NN timesX∼Poisson(λ/2)X \sim \text{Poisson}(\lambda/2)
Poisson(30) split 50/50independent Poisson(15), Poisson(15)
IPL overfX(t)=∑yfY(y)fX∣Y=y(t)f_X(t) = \sum_y f_Y(y) f_{X \mid Y = y}(t)

Exam tips: last-minute checklist

Do
  • Check every PMF table adds to 1 (find unknown constants from this)
  • Marginal: sum out everything you do not keep
  • Conditional: joint ÷\div marginal of what is given
  • Independence: product rule in every cell
  • Total probability: weight each branch, then add
  • Chain rule: each factor conditions on all earlier variables
Do not
  • Rebuild a joint from marginals unless independent
  • Divide by the wrong marginal in a conditional
  • Assume pairwise independence means mutual independence
  • Add conditional PMFs without the branch weights
  • Call a variable independent after checking one cell
  • Condition on a probability-0 value

Which tool for which question?

Question saysUse
"probability that X = a and Y = b"joint PMF cell
"distribution of X alone"marginalisation (sum out Y)
"given that ..."conditional = joint ÷ marginal
"two stages", "first ... then ..."total probability with a tree, or joint = marginal × conditional
"are X and Y independent?"product rule in every cell
"probability of the cause given the effect"Bayes: branch contribution ÷ total
"in how many ways / without replacement"counting with binomial coefficients, or the chain rule
Back to top