- [[marginal probability]]
# Idea
Conditional probability is denoted as follows:
$P(X|Y)$
It's the probability of $X$, given $Y$: The probability of snow, given it is January. The probability of feeling hungry, given it is midnight.
Example: If a house on the street has a cat, find the probability the the house also having a dog. Expressed as conditional probability:
$P(dog|cat)$
![[s20220326_225922.png]]
![[s20220326_230654.png]]
10 houses have cats. 3 houses have cats **and** dogs. So $P(dog|cat) = \frac{3}{10}$, because 3 out of the 10 houses with cats also have dogs.
Another way to put it: 10 of 22 houses have cats, $P(cat) = \frac{10}{22}$. 3 of 22 houses have cats **and** dogs, $P(cat \cap dog) = \frac{3}{22}$. So $P(dog|cat) = \frac{P(cat \cap dog)}{P(cat)} = \frac{\frac{3}{22}}{\frac{10}{22}} = \frac{3}{10}$.
Thus, more generally,
$P(A|B) = \frac{P(A \cap B)}{P(B)}$
Or
$P(B|A) = \frac{P(A \cap B)}{P(A)}$
## Relationship to joint probability
Conditional probability is used to describe dependence and to calculate [[joint probability of dependent events]].
![[s20220326_005551.png|600]]
![[s20220326_225533.png|600]]
When we see $P(A|B)$, what we mean is that **given that we have already observed $B$**, then we know that our sample space must be within the green region $B$ (thus, $P(B)$ to denote the probability of observing $B$).
Now, $P(A|B)$ tells us $A$ can only occur within sample space $B$, so the event $P(A|B)$ must happen at the intersection of $A$ and $B$, denoted $P(A \cap B)$.
Thus, $P(A|B)$ is the ratio of the intersection region $P(A \cap B)$ as a fraction/proportion of the sample space of $B$, $P(B)$:
$P(A|B) = \frac{P(A \cap B)}{P(B)}$
When we eliminate the denominator on the right-hand-side by multiplying both sides by $P(B)$, we get this equation (which is described more in [[joint probability of dependent events]]):
$P(A \cap B) = P(A|B) \ P(B) $
# References
- [Lesson Video: Conditional Probability | Nagwa](https://www.nagwa.com/en/videos/183106462819/)
- [Conditional Probability Definition](https://www.investopedia.com/terms/c/conditional_probability.asp)
- [Conditional probability explained visually](https://setosa.io/conditional/)