# Independence and conditional independence

Independence and conditional independence are one of the most basic concepts in probabilities. Two random variables are independent, as the term suggested, if the outcome of one variable should not affect the outcome of another. Mathematically, two variables $X$ and $Y$ are independent if $p(x,y) = p(x) p(y)$ for any outcome $x$ for variable $X$ and outcome $y$ for variable $Y$. And we often indicate this independece by $X \bot Y$.

Let’s inspect this definition more carefully, given $Y=y$ and by Bayes’ rule, the probability of $X=x$ is

$Pr(X=x|Y=y)=\frac{p(x,y)}{p(y)}= \frac{p(x)p(y)}{p(y)}=p(x)$. Indeed the probability does not depend on the outcome of $Y$ and so $X$ and $Y$ are independent.

Similarly, when we say $X$ and $Y$ are conditionally independent given $Z$, it means that knowing $Z$, $X$ and $Y$ become independent. Note that $X$ and $Y$ do not need to be independent to start with. Many students have the misconceptions that independence implies conditional independence, or vice versa. The fact is that they are completely unrelated concepts. We can easily find examples that variables are independent but not conditional independent and vice versa. And also examples that variables are both independent and conditional independent. And of course cases when neither independence is satisfied.

Mathematically, we denote the independence by $X \bot Y|Z$, and we have $p(x,y|z)=p(x|z)p(y|z)$ for any $x, y$, and $z$.

Note that the definition above implies that $p(x|y,z)=\frac{p(x,y|z)}{p(y|z)}=p(x|z)$. Hence, indeed if we are given $z$, the probability of $X=x$ does not dependent on the outcome of $Y$. So it depicts well the conditional independence that we anticipated.