A note on Conditional Probability and Conditional Expectation
Prof. Soumen Manna
Goa Institute of Management, Goa, India
Let X and Y are two random variables. In this note, we will learn how to solve any problem regarding
conditional probability or conditional expectation under joint distribution (X,Y ).
1. Conditional Probability
Any question regarding conditional probability falls under the following form
P(X ∈ A|Y ∈ B),
where, A and B are subsets of the sample space of X and Y , respectively.
1.1. When X and Y are discrete
Let f (x, y) be the joint pmf of (X,Y ) and f (x), f (y) are the marginal pmf for X, Y , respectively.
Case-1: If both A = {x0 } and B = {y0 } contain singleton point. Then
P(X = x0 , Y = y0 ) f (x0 , y0 )
P(X ∈ A|Y ∈ B) ≡ P(X = x0 |Y = y0 ) = = .
P(Y = y0 ) f (y0 )
Case-2: If A = {x0 }, a singleton point, and B = {y1 , y2 , . . . , yn } contains n point. Then
n
P(X = x0 , Y ∈ {y1 , y2 , . . . , yn }) ∑ j=1 f (x0 , y j )
P(X ∈ A|Y ∈ B) ≡ P(X = x0 |Y ∈ {y1 , y2 , . . . , yn }) = = .
P(Y ∈ {y1 , y2 , . . . , yn }) ∑nj=1 f (y j )
Case-3: If A = {x1 , x2 , . . . , xm } contains m points and B = {y0 } contains a singleton point. Then
P(X ∈ {x1 , x2 , . . . , xm }, Y = y0 ) ∑m f (xi , y0 )
P(X ∈ A|Y ∈ B) ≡ P(X ∈ {x1 , x2 , . . . , xm }|Y = y0 ) = = i=1 .
P(Y = y0 ) f (y0 )
Case-4: If A = {x1 , x2 , . . . , xm } contains m points, and B = {y1 , y2 , . . . , yn } contains n point. Then
P(X ∈ A|Y ∈ B)
≡ P(X ∈ {x1 , x2 , . . . , xm }|Y ∈ {y1 , y2 , . . . , yn })
m n
P(X ∈ {x1 , x2 , . . . , xm }, Y ∈ {y1 , y2 , . . . , yn }) ∑i=1 ∑ j=1 f (xi , y j )
= = .
P(Y ∈ {y1 , y2 , . . . , yn }) ∑nj=1 f (y j )
1.2. When X and Y are continuous
Let f (x, y) is the joint pdf of (X,Y ) and f (x), f (y) are the marginal pdf for X, Y , respectively.
Case-1: If both A = {x0 } and B = {y0 } contain singleton point. Then
P(X ∈ A|Y ∈ B) ≡ P(X = x0 |Y = y0 ) = 0 (single point for conditional density X).
Preprint submitted to SPL August 6, 2023
Case-2: If A = {x0 }, a singleton point, and B is an interval (c, d). Then
P(X ∈ A|Y ∈ B) ≡ P(X = x0 |Y ∈ (c, d)) = 0 (single point for conditional density X).
Case-3: If A is an interval (a, b) and B = {y0 } contains a singleton point. Then you need to first calculate
f (x, y0 )
f (x|y0 ) = .
f (y0 )
And then, Z b
P(X ∈ A|Y ∈ B) ≡ P(X ∈ (a, b)|Y = y0 ) = f (x|y0 ) dx.
a
Case-4: If A is an interval (a, b) and B is an interval (c, d). Then you need to first calculate
Rd
f (x, y) dy
f (x|y ∈ (c, d)) = Rc d .
c f (y) dy
And then, Z b
P(X ∈ A|Y ∈ B) ≡ P(X ∈ (a, b)|Y ∈ (c, d)) = f (x|y ∈ (c, d)) dx.
a
2. Conditional Expectation
Any question regarding conditional expectation falls under the following form
E(g(X)|Y ∈ B),
where, g(X) is a function of X and B is a subset of the sample space of Y .
2.1. When X and Y are discrete
Let f (x, y) be the joint pmf of (X,Y ) and f (x), f (y) are the marginal pmf for X, Y , respectively. Let R(x)
is the range of X.
Case-1: If B = {y0 } contains a singleton point. Then first find the conditional pmf function f (x|y0 ) as
P(X = x, Y = y0 ) f (x, y0 )
f (x|y0 ) = = (for all x ∈ R(x)).
P(Y = y0 ) f (y0 )
And then
E(g(X)|Y = y0 ) = ∑ g(xi ) f (xi |y0 ).
xi ∈R(x)
Case-2: If B = {y1 , y2 , . . . , yn } contains n points. Then first find the conditional pmf function f (x|y ∈ B) as
n
P(X = x, Y ∈ {y1 , y2 , . . . , yn }) ∑ j=1 f (x, y j )
f (x|y ∈ B) = = n , (for all x ∈ R(x)).
P(Y ∈ {y1 , y2 , . . . , yn }) ∑ j=1 f (y j )
And then
E(g(X)|Y ∈ B) = ∑ g(xi ) f (xi |y ∈ B).
xi ∈R(x)
2.2. When X and Y are continuous
Let f (x, y) be the joint pdf of (X,Y ) and f (x), f (y) are the marginal pdf for X, Y , respectively.
2
Case-1: If B = {y0 } contains a singleton point. Then, first find the conditional pdf function f (x|y0 ) as
f (x, y0 )
f (x|y0 ) = .
f (y0 )
Then Z ∞
E(g(X)|Y = y0 ) = g(x) f (x|y0 ) dx.
−∞
Case-2: If B = (c, d) is an interval. Then, first find the conditional pdf function f (x|y ∈ (c, d)) as
Rd
f (x, y) dy
f (x|y ∈ (c, d)) = Rc d .
c f (y) dy
Then Z ∞
E(g(X)|Y ∈ (c, d)) = g(x) f (x|y ∈ (c, d)) dx.
−∞
Here, in this note, we describe rules for (X|Y ) variable. If question comes for (Y |X) variable, the roles of X
and Y will interchange for the above rules accordingly.