Books Probability and Statistical Inference

Conditional Distributions

Definition 4.3

The conditional probability mass function of 𝑋𝑋 given 𝑌=𝑦𝑌=𝑦 is defined by

𝑔(𝑥∣𝑦)=𝑓(𝑥,𝑦)𝑓𝑌(𝑦),provided that 𝑓𝑌(𝑦)>0.𝑔(𝑥|𝑦)=\frac{𝑓(𝑥,𝑦)}{{𝑓}_{𝑌}(𝑦)},\quad \text{provided that}\, {𝑓}_{𝑌}(𝑦)>0.

Similarly, the conditional probability mass function of 𝑌𝑌 given 𝑋=𝑥𝑋=𝑥 is defined by

h(𝑦∣𝑥)=𝑓(𝑥,𝑦)𝑓𝑋(𝑥),provided that 𝑓𝑋(𝑥)>0.h(𝑦|𝑥)=\frac{𝑓(𝑥,𝑦)}{{𝑓}_{𝑋}(𝑥)},\quad \text{provided that}\, {𝑓}_{𝑋}(𝑥)>0.

Note that h(𝑦∣𝑥)≥0h(𝑦|𝑥)\geq 0, and summing it over 𝑦𝑦 gives

∑𝑦h(𝑦∣𝑥)=∑𝑦𝑓(𝑥,𝑦)𝑓𝑋(𝑥)=1𝑓𝑋(𝑥)∑𝑦𝑓(𝑥,𝑦)=1𝑓𝑋(𝑥)⋅𝑓𝑋(𝑥)=1.\sum _{𝑦}h(𝑦|𝑥)=\sum _{𝑦}\frac{𝑓(𝑥,𝑦)}{{𝑓}_{𝑋}(𝑥)}=\frac{1}{{𝑓}_{𝑋}(𝑥)}\sum _{𝑦}𝑓(𝑥,𝑦)=\frac{1}{{𝑓}_{𝑋}(𝑥)}\cdot {𝑓}_{𝑋}(𝑥)=1.

This shows that h(𝑦∣𝑥)h(𝑦|𝑥) is a valid probability mass function. We may compute probaility of event like {𝑎≤𝑌≤𝑏}\{𝑎\leq 𝑌\leq 𝑏\} given 𝑋=𝑥𝑋=𝑥 as

P(𝑎≤𝑌≤𝑏∣𝑋=𝑥)=∑𝑎≤𝑦≤𝑏h(𝑦∣𝑥)ℙ(𝑎\leq 𝑌\leq 𝑏|𝑋=𝑥)=\sum _{𝑎\leq 𝑦\leq 𝑏}h(𝑦|𝑥)

and compute conditional expectation of a function 𝑢(𝑌)𝑢(𝑌) given 𝑋=𝑥𝑋=𝑥 as

E[𝑢(𝑌)∣𝑋=𝑥]=∑𝑦𝑢(𝑦)h(𝑦∣𝑥).\mathbb{E}[𝑢(𝑌)|𝑋=𝑥]=\sum _{𝑦}𝑢(𝑦)h(𝑦|𝑥).
Note
Note that the conditional expectation of 𝑌𝑌 given 𝑋=𝑥𝑋=𝑥 is a function of 𝑥𝑥.

Two special conditional expectations are conditional mean

μ𝑌∣𝑥=E[𝑌∣𝑋=𝑥]=∑𝑦𝑦h(𝑦∣𝑥),{\mu }_{𝑌|𝑥}=\mathbb{E}[𝑌|𝑋=𝑥]=\sum _{𝑦}𝑦h(𝑦|𝑥),

and conditional variance

σ𝑌∣𝑥2=E[(𝑌−μ𝑌∣𝑥)2∣𝑋=𝑥]=∑𝑦(𝑦−μ𝑌∣𝑋)2h(𝑦∣𝑥).{\sigma }_{𝑌|𝑥}^{2}=\mathbb{E}[{(𝑌-{\mu }_{𝑌|𝑥})}^{2}|𝑋=𝑥]=\sum _{𝑦}{(𝑦-{\mu }_{𝑌}|𝑋)}^{2}h(𝑦|𝑥).

One can show that

σ𝑌∣𝑥2=E[𝑌2∣𝑋=𝑥]−(E[𝑌∣𝑋=𝑥])2=E[𝑌2∣𝑋=𝑥]−μ𝑌∣𝑥2.{\sigma }_{𝑌|𝑥}^{2}=\mathbb{E}[{𝑌}^{2}|𝑋=𝑥]-{(\mathbb{E}[𝑌|𝑋=𝑥])}^{2}=\mathbb{E}[{𝑌}^{2}|𝑋=𝑥]-{\mu }_{𝑌|𝑥}^{2}.
Exercise 4.5

Let 𝑋𝑋 and 𝑌𝑌 be random variables of discrete type. Show that if μ𝑌∣𝑥{\mu }_{𝑌|𝑥} is linear in 𝑥𝑥 (we have already noted that it is a function of 𝑥𝑥), i.e., μ𝑌∣𝑥=𝑎+𝑏𝑥{\mu }_{𝑌|𝑥}=𝑎+𝑏𝑥, then it is given by the formula

μ𝑌∣𝑥=μ𝑌+ρσ𝑌σ𝑋(𝑥−μ𝑋).{\mu }_{𝑌|𝑥}={\mu }_{𝑌}+\rho \frac{{\sigma }_{𝑌}}{{\sigma }_{𝑋}}(𝑥-{\mu }_{𝑋}).
(4.6)

Similarly, if μ𝑋∣𝑦{\mu }_{𝑋|𝑦} is linear in 𝑦𝑦, then

μ𝑋∣𝑦=μ𝑋+ρσ𝑋σ𝑌(𝑦−μ𝑌).{\mu }_{𝑋|𝑦}={\mu }_{𝑋}+\rho \frac{{\sigma }_{𝑋}}{{\sigma }_{𝑌}}(𝑦-{\mu }_{𝑌}).
(4.7)
Remark
The formula for μ𝑌∣𝑥{\mu }_{𝑌|𝑥} is the same as the equation for the best-fitting line (least squares regression line) in Exercise 4.4.
Proof

We have

μ𝑌=E[μ𝑌∣𝑋]=E[𝑎+𝑏𝑋]=𝑎+𝑏μ𝑋.{\mu }_{𝑌}=\mathbb{E}[{\mu }_{𝑌|𝑋}]=\mathbb{E}[𝑎+𝑏𝑋]=𝑎+𝑏{\mu }_{𝑋}.

Then, we study E[𝑋𝑌]\mathbb{E}[𝑋𝑌]. We have

E[𝑋𝑌]=∑𝑥∑𝑦𝑥𝑦𝑓(𝑥,𝑦)=∑𝑥∑𝑦𝑥𝑦h(𝑦∣𝑥)𝑓𝑋(𝑥)=∑𝑥𝑥𝑓𝑋(𝑥)∑𝑦𝑦h(𝑦∣𝑥)=∑𝑥𝑥𝑓𝑋(𝑥)μ𝑌∣𝑥Plug in the formula for μ𝑌∣𝑥=∑𝑥𝑥(𝑎+𝑏𝑥)𝑓𝑋(𝑥)=𝑎μ𝑋+𝑏(σ𝑋2+μ𝑋2).\begin{aligned}\mathbb{E}[𝑋𝑌] & =\sum _{𝑥}\sum _{𝑦}𝑥𝑦𝑓(𝑥,𝑦) \\ & =\sum _{𝑥}\sum _{𝑦}𝑥𝑦h(𝑦|𝑥){𝑓}_{𝑋}(𝑥) \\ & =\sum _{𝑥}𝑥{𝑓}_{𝑋}(𝑥)\sum _{𝑦}𝑦h(𝑦|𝑥) \\ & =\sum _{𝑥}𝑥{𝑓}_{𝑋}(𝑥){\mu }_{𝑌|𝑥} \\ & \text{Plug in the formula for}\, {\mu }_{𝑌|𝑥} \\ & =\sum _{𝑥}𝑥(𝑎+𝑏𝑥){𝑓}_{𝑋}(𝑥) \\ & =𝑎{\mu }_{𝑋}+𝑏({\sigma }_{𝑋}^{2}+{\mu }_{𝑋}^{2}).\end{aligned}

Combined with the equation Cov⁡(𝑋,𝑌)=E[𝑋𝑌]−μ𝑋μ𝑌\operatorname{Cov}(𝑋,𝑌)=\mathbb{E}[𝑋𝑌]-{\mu }_{𝑋}{\mu }_{𝑌}, we get a system of equations

{E[𝑋𝑌]=𝑎μ𝑋+𝑏(σ𝑋2+μ𝑋2)E[𝑋𝑌]=μ𝑋μ𝑌+ρσ𝑋σ𝑌\begin{cases}\mathbb{E}[𝑋𝑌] & =𝑎{\mu }_{𝑋}+𝑏({\sigma }_{𝑋}^{2}+{\mu }_{𝑋}^{2}) \\ \mathbb{E}[𝑋𝑌] & ={\mu }_{𝑋}{\mu }_{𝑌}+\rho {\sigma }_{𝑋}{\sigma }_{𝑌}\end{cases}

Equate the RHS of the two equations,

𝑎μ𝑋+𝑏(σ𝑋2+μ𝑋2)=μ𝑋μ𝑌+ρσ𝑋σ𝑌.𝑎{\mu }_{𝑋}+𝑏({\sigma }_{𝑋}^{2}+{\mu }_{𝑋}^{2})={\mu }_{𝑋}{\mu }_{𝑌}+\rho {\sigma }_{𝑋}{\sigma }_{𝑌}.

Substitute μ𝑌=𝑎+𝑏μ𝑋{\mu }_{𝑌}=𝑎+𝑏{\mu }_{𝑋},

𝑎μ𝑋+𝑏(σ𝑋2+μ𝑋2)=𝑎μ𝑋+𝑏μ𝑋2+ρσ𝑋σ𝑌.𝑎{\mu }_{𝑋}+𝑏({\sigma }_{𝑋}^{2}+{\mu }_{𝑋}^{2})=𝑎{\mu }_{𝑋}+𝑏{\mu }_{𝑋}^{2}+\rho {\sigma }_{𝑋}{\sigma }_{𝑌}.

Simplify,

𝑏=ρσ𝑌σ𝑋.𝑏=\rho \frac{{\sigma }_{𝑌}}{{\sigma }_{𝑋}}.

Then, the value of 𝑎𝑎 is given by

𝑎=μ𝑌−ρσ𝑌σ𝑋⋅μ𝑋.𝑎={\mu }_{𝑌}-\rho \frac{{\sigma }_{𝑌}}{{\sigma }_{𝑋}}\cdot {\mu }_{𝑋}.

Therefore, we obtain the formula for μ𝑌∣𝑥{\mu }_{𝑌|𝑥}

μ𝑌∣𝑥=μ𝑌+ρσ𝑌σ𝑋(𝑥−μ𝑋).{\mu }_{𝑌|𝑥}={\mu }_{𝑌}+\rho \frac{{\sigma }_{𝑌}}{{\sigma }_{𝑋}}(𝑥-{\mu }_{𝑋}).

Similarly, by swapping the roles of 𝑋𝑋 and 𝑌𝑌, we can show that

μ𝑋∣𝑦=μ𝑋+ρσ𝑋σ𝑌(𝑦−μ𝑌).{\mu }_{𝑋|𝑦}={\mu }_{𝑋}+\rho \frac{{\sigma }_{𝑋}}{{\sigma }_{𝑌}}(𝑦-{\mu }_{𝑌}).

As a quick follow-up, we note that if both μ𝑌∣𝑥{\mu }_{𝑌|𝑥} and μ𝑋∣𝑦{\mu }_{𝑋|𝑦} are linear in 𝑥𝑥 and 𝑦𝑦, respectively, then the product of the slopes of the two lines is ρ2{\rho }^{2} and the quotient is σ𝑌2/σ𝑋2{\sigma }_{𝑌}^{2}/{\sigma }_{𝑋}^{2} (slope of line μ𝑌∣𝑥{\mu }_{𝑌|𝑥} divided by the slope of line μ𝑋∣𝑦{\mu }_{𝑋|𝑦}).

Example 4.4

Let us yet again revisit the example of the trinomial distribution. Let 𝑋𝑋 and 𝑌𝑌 have the trinomial distribution with parameters 𝑛𝑛, 𝑝𝑋>0{𝑝}_{𝑋}>0, and 𝑝𝑌>0{𝑝}_{𝑌}>0. The joint PMF is given by

𝑓(𝑥,𝑦)=𝑛!𝑥!𝑦!(𝑛−𝑥−𝑦)!𝑝𝑋𝑥𝑝𝑌𝑦(1−𝑝𝑋−𝑝𝑌)𝑛−𝑥−𝑦.𝑓(𝑥,𝑦)=\frac{𝑛!}{𝑥!𝑦!(𝑛-𝑥-𝑦)!}{𝑝}_{𝑋}^{𝑥}{𝑝}_{𝑌}^{𝑦}{(1-{𝑝}_{𝑋}-{𝑝}_{𝑌})}^{𝑛-𝑥-𝑦}.

As noted before, 𝑋∼Bin⁡(𝑛,𝑝𝑋)𝑋∼\operatorname{Bin}(𝑛,{𝑝}_{𝑋}). Thus, the marginal PMF of 𝑋𝑋 is

𝑓𝑋(𝑥)=𝑛!𝑥!(𝑛−𝑥)!𝑝𝑋𝑥(1−𝑝𝑋)𝑛−𝑥.{𝑓}_{𝑋}(𝑥)=\frac{𝑛!}{𝑥!(𝑛-𝑥)!}{𝑝}_{𝑋}^{𝑥}{(1-{𝑝}_{𝑋})}^{𝑛-𝑥}.

We are now interested in the conditional of 𝑌𝑌 given 𝑋=𝑥𝑋=𝑥. By definition, the conditional PMF of 𝑌𝑌 given 𝑋=𝑥𝑋=𝑥 is given by

h(𝑦∣𝑥)=𝑓(𝑥,𝑦)𝑓𝑋(𝑥)=(𝑛−𝑥)!𝑦!(𝑛−𝑥−𝑦)!⋅(𝑝𝑌1−𝑝𝑋)𝑦(1−𝑝𝑋−𝑝𝑌1−𝑝𝑋)𝑛−𝑥−𝑦.h(𝑦|𝑥)=\frac{𝑓(𝑥,𝑦)}{{𝑓}_{𝑋}(𝑥)}=\frac{(𝑛-𝑥)!}{𝑦!(𝑛-𝑥-𝑦)!}\cdot {\left(\frac{{𝑝}_{𝑌}}{1-{𝑝}_{𝑋}}\right)}^{𝑦}{\left(\frac{1-{𝑝}_{𝑋}-{𝑝}_{𝑌}}{1-{𝑝}_{𝑋}}\right)}^{𝑛-𝑥-𝑦}.

By comparing with the binomial PMF, we see that h(𝑦∣𝑥)h(𝑦|𝑥) is the PMF of

Bin⁡(𝑛−𝑥,𝑝𝑌1−𝑝𝑋).\operatorname{Bin}\left(𝑛-𝑥,\frac{{𝑝}_{𝑌}}{1-{𝑝}_{𝑋}}\right).

The conditional mean of 𝑌𝑌 given 𝑋=𝑥𝑋=𝑥 is simply the mean of the above binomial distribution, i.e.,

μ𝑌∣𝑥=𝑝𝑌1−𝑝𝑋(𝑛−𝑥).{\mu }_{𝑌|𝑥}=\frac{{𝑝}_{𝑌}}{1-{𝑝}_{𝑋}}(𝑛-𝑥).

Note that this is a linear function of 𝑥𝑥. Therefore, by Exercise 4.5, we have

μ𝑌∣𝑥=μ𝑌+ρσ𝑌σ𝑋(𝑥−μ𝑋).{\mu }_{𝑌|𝑥}={\mu }_{𝑌}+\rho \frac{{\sigma }_{𝑌}}{{\sigma }_{𝑋}}(𝑥-{\mu }_{𝑋}).

Similarly, by swapping the roles of 𝑋𝑋 and 𝑌𝑌, the conditional distribution of 𝑋𝑋 given 𝑌=𝑦𝑌=𝑦 is Bin⁡(𝑛−𝑦,𝑝𝑋/(1−𝑝𝑌))\operatorname{Bin}(𝑛-𝑦,{𝑝}_{𝑋}/(1-{𝑝}_{𝑌})) and the conditional mean of 𝑋𝑋 given 𝑌=𝑦𝑌=𝑦 is

μ𝑋∣𝑦=𝑝𝑋1−𝑝𝑌(𝑛−𝑦).{\mu }_{𝑋|𝑦}=\frac{{𝑝}_{𝑋}}{1-{𝑝}_{𝑌}}(𝑛-𝑦).

As noted before, the product of the coefficients of the variables of the two conditional means is ρ2{\rho }^{2}. Therefore, we have

ρ2=(−𝑝𝑌1−𝑝𝑋)(−𝑝𝑋1−𝑝𝑌)=𝑝𝑋𝑝𝑌(1−𝑝𝑋)(1−𝑝𝑌).{\rho }^{2}=\left(-\frac{{𝑝}_{𝑌}}{1-{𝑝}_{𝑋}}\right)\left(-\frac{{𝑝}_{𝑋}}{1-{𝑝}_{𝑌}}\right)=\frac{{𝑝}_{𝑋}{𝑝}_{𝑌}}{(1-{𝑝}_{𝑋})(1-{𝑝}_{𝑌})}.

And becuase the correlation coefficient of the trinomial distribution is negative, we have

ρ=−𝑝𝑋𝑝𝑌(1−𝑝𝑋)(1−𝑝𝑌).\rho =-\sqrt{\frac{{𝑝}_{𝑋}{𝑝}_{𝑌}}{(1-{𝑝}_{𝑋})(1-{𝑝}_{𝑌})}}.