Conditional Probability
• Conditional probability: for events E and F :
P (E | F ) =
P (EF )
P (F )
• Conditional probability mass function (pmf)
pX|Y (x | y) = P{X = x | Y = y}
=
P{X = x, Y = y}
P{Y = y}
=
p(x, y)
pY (y)
defined for y : pY (y) > 0.
• Conditional expectation of X given Y = y
E[X | Y = y] =
∑
x
xpX|Y (x | y)
• If X and Y are independent, then E[X | Y = y] =
E[X ].
1
Examples
1. Suppose the joint pmf ofX and Y is given by p(1, 1) =
0.5, p(1, 2) = 0.1, p(2, 1) = 0.1, p(2, 2) = 0.3. Find
the pmf of X given Y = 1.
Solution:
pX|Y=1(1) = p(1, 1)/pY (1) = 0.5/0.6 = 5/6
pX|Y=1(2) = p(2, 1)/pY (1) = 0.1/0.6 = 1/6
2. IfX and Y are independent Poisson RVs with respec-
tive means λ1 and λ2, find the conditional pmf of X
given X + Y = n and the conditional expected value
of X given X + Y = n.
Solution:
Let Z = X + Y . We want to find pX|Z=n(k). For
k = 0, 1, 2, ..., n
pX|Z=n(k) =
P (X = k, Z = n)
P (Z = n)
=
P (X = k,X + Y = n)
P (Z = n)
=
P (X = k, Y = n− k)
P (Z = n)
=
P (X = k)P (Y = n− k)
P (Z = n)
2
We know that Z is Poisson with mean λ1 + λ2.
pX|Z=n(k) =
P (X = k, Z = n)
P (Z = n)
=
P (X = k)P (Y = n− k)
P (Z = n)
=
e−λ1 ·
λk1
k! · e
−λ2 ·
λn−k2
(n−k)!
e−(λ1+λ2) · (λ1+λ2)
n
n!
=
(
n
k
)
·
(
λ1
λ1 + λ2
)k
·
(
λ2
λ1 + λ2
)n−k
Hence the conditional distribution of X given X +
Y = n is a binomial distribution with parameters n
and λ1λ1+λ2 .
E(X|X + Y = n) =
λ1n
λ1 + λ2
.
3. Consider n+m independent trials, each of which re-
sults in a success with probability p. Compute the ex-
pected number of successes in the first n trials given
that there are k successes in all.
Solution: Let Y be the number of successes in n+m
trials. Let X be the number of successes in the first n
trials. Define
Xi =
{
1 if the ith trial is a success
0 otherwise
3
The X =
∑n
i=1Xi.
E(X|Y = k) = E(
n∑
i=1
Xi|Y = k) =
n∑
i=1
E(Xi|Y = k)
Since the trials are independent Xi|Y = k have the
same distribution. Hence
E(Xi|Y = k) = P (Xi = 1|Y = k) = P (Xi = 1|Y = k)
P (X1 = 1|Y = k) =
P (X1 = 1, Y = k)
P (Y = k)
=
(
n + m− 1
k − 1
)
· pk · (1 − p)n+m−k
(
n + m
k
)
· pk · (1 − p)n+m−k
=
k
n + m
Hence
E(X|Y = k) =
nk
n + m
4
Conditional Density
• Conditional probability density function:
fX|Y (x | y) =
f(x, y)
fY (y)
defined for y : fY (y) > 0.
• P (X ∈ R | Y = y) =
∫
R fX|Y (x | y)dx
• Conditional expectation of X given Y = y
E[X | Y = y] =
∫ ∞
−∞
xfX|Y (x | y)dx
• For function g, the conditional expectation of g(X)
E[g(X) | Y = y] =
∫ ∞
−∞
g(x)fX|Y (x | y)dx
5
Computing Expectation by Conditioning
• Discrete:
E[X ] =
∑
y
E[X | Y = y]pY (y)
=
∑
y
∑
x
xpX|Y (x | y)pY (y)
• Continuous:
E[X ] =
∫ ∞
−∞
E[X | Y = y]fY (y)dy
=
∫ ∞
−∞
∫ ∞
−∞
xfX|Y (x | y)fY (y)dxdy
• Chain expansion: E[X ] = EY [EX|Y (X | Y )].
6
• Expectation of the sum of a random number of ran-
dom variables:
If X =
∑N
i=1Xi, N is a random variable independent
of Xi’s. Xi’s have common mean µ. Then E[X ] =
E[N ]µ.
• Example: Suppose that the expected number of acci-
dents per week at an industrial plant is four. Suppose
also that the numbers of workers injured in each acci-
dent are independent random variables with a com-
mon mean of 2. Assume also that the number of
workers injured in each accident is independent of the
number of accidents that occur. What is the expected
number of injuries during a week?
• The variance of a random number of random vari-
ables:
Z =
∑N
i=1Xi, E(Xi) = µ, V ar(Xi) = σ
2
,
V ar(Z) = σ2E[N ] + µ2V ar(N).
7
Computing Probability by Conditioning
• Total probability formula: Suppose F1, F2, ..., Fn are
mutually exclusive and ∪ni=1Fi = S
P (E) =
n∑
i=1
P (Fi)P (E | Fi)
• pX(x) =
∑
yi
pX|Y (x | yi)pY (yi).
• fX(x) =
∫∞
−∞ fX|Y (x | y)fY (y)dy.
8