## Conditional Independence

Two random variable $X$ and $Y$ are conditiaonly independent given $Z$, denoted by $X \perp \!\! \perp Y \mid Z$ if 

$$p_{X,Y\mid Z} (x,y\mid z) = p_{X\mid Z}(x\mid z) \, p_{Y\mid Z}(y\mid z)$$

In general Marginal independence doesn't imply conditional independence and vice versa. 

### Example 

R: Red Sox Game <br>
A: Accident     <br>
T: Bad Traffic  



Find the following probability

(a) $\mathbb{P}(R=1) = 0.5$

(b) $\mathbb{P}(R=1 \mid T=1)$

$$\begin{align}p_{R,A}(r,a\mid 1) 
&= \frac{p_{T\mid R,A}(1 \mid r, a)\, p_R(r) \, p_A(a)}{p_T(1)}\\
&= c\cdot p_{T\mid R,A}(1 \mid r, a)\end{align}$$

(c) $\mathbb{P}(R=1 \mid T=1, A=1)= \mathbb{P}(R=1 \mid T=1)$

### Practice Problem: Conditional Independence

Suppose $X_0, \dots , X_{100}$ are random variables whose joint distribution has the following factorization:

$$p_{X_0, \dots , X_{100}}(x_0, \dots , x_{100}) = p_{X_0}(x_0) \cdot \prod _{i=1}^{100} p_{X_ i | X_{i-1}}(x_ i | x_{i-1})$$
 
This factorization is what's called a Markov chain. We'll be seeing Markov chains a lot more later on in the course.

Show that $X_{50} \perp \!\! \perp X_{52} \mid X_{51}$.

**Answer:** 
$$
\begin{eqnarray}
		p_{X_{50},X_{51},X_{52}}(x_{50},x_{51},x_{52})
        &=& \sum_{x_{0} \dots x_{49}} \sum_{x_{53} \dots x_{100}} p_{X_0, \dots , X_{100}}(x_0, \dots , x_{100})  \\
		&=& \sum_{x_{0} \dots x_{49}} \sum_{x_{53} \dots x_{100}} \left[p_{X_0}(x_{0}) \prod_{i=0}^{50} p_{X_i\mid X_{i-1}}(x_{i}|x_{i-1})\right] \\
        && \cdot \prod_{i=51}^{52} p_{X_i\mid X_{i-1}}(x_{i}|x_{i-1})\cdot \prod_{i=53}^{100}  p_{X_i\mid X_{i-1}}(x_{i}|x_{i-1}) \\
        &=& \underbrace{\sum_{x_{0} \dots x_{49}}  \left[p_{X_0}(x_{0}) \prod_{i=0}^{50} p_{X_i\mid X_{i-1}}(x_{i}|x_{i-1})\right]}_{=p_{X_{50}}(x_{50})} \\
        && \cdot \prod_{i=51}^{52} p_{X_i\mid X_{i-1}}(x_{i}|x_{i-1})\cdot \underbrace{\sum_{x_{53} \dots x_{100}}\prod_{i=53}^{100}  p_{X_i\mid X_{i-1}}(x_{i}|x_{i-1})}_{=1} \\[2ex]
		&=& p_{X_{50}}(x_{50}) \cdot p_{X_{51}\mid X_{50}}(x_{51}|x_{50}) \cdot p_{X_{52}\mid X_{51}}(x_{52}|x_{51}) \\[2ex]
        &=&  p_{X_{50}\mid X_{51}}(x_{50}|x_{51}) \cdot p_{X_{52}\mid X_{51}}(x_{52}|x_{51}) \\[2ex]
        \frac{p_{X_{50},X_{51},X_{52}}(x_{50},x_{51},x_{52})}{p_{X_{51}}(x_{51})} 
        &=& p_{X_{50}\mid X_{51}}(x_{50}|x_{51}) \cdot p_{X_{52}\mid X_{51}}(x_{52}|x_{51}) \\[2ex]
        p_{X_{50},X_{52}\mid X_{51}}(x_{50},x_{52}\mid x_{51}) 
        &=& p_{X_{50}\mid X_{51}}(x_{50}|x_{51}) \cdot p_{X_{52}\mid X_{51}}(x_{52}|x_{51})
\end{eqnarray}
$$


```python

```

233c7dc2b288c1f2a69cc16e242012c3fc7412b8
ipynb
Jupyter Notebook
week03/03 Conditional Independence.ipynb
infimath/Computational-Probability-and-Inference
e48cd52c45ffd9458383ba0f77468d31f781dc77
MIT
2019-04-04T03:07:47.000Z
2019-04-04T03:07:47.000Z
week03/03 Conditional Independence.ipynb
infimath/Computational-Probability-and-Inference
e48cd52c45ffd9458383ba0f77468d31f781dc77
MIT
week03/03 Conditional Independence.ipynb
infimath/Computational-Probability-and-Inference
e48cd52c45ffd9458383ba0f77468d31f781dc77
MIT
2021-02-27T05:33:49.000Z
2021-02-27T05:33:49.000Z
Qwen/Qwen-72B
1. YES
2. YES