# Calculating conditional probability with marginal

Assume we are given a joint distribution $$P(X,Y)$$ where $$P(0,0)=0.1$$, $$P(0,1) = 0.4$$, $$P(1,0)=0.3$$, and $$P(1,1)=0.2$$. The goal is to compute $$P(X|Y=1)$$.

Traditionally, solving a conditional probability problem $$P(A|B)$$ simplifies to $$\frac{P(A,B)}{P(B)}$$, but I'm unsure how to apply it to this case. In particular, I am unclear on what the probability $$P(X,Y=1)$$ means since $$P(X)$$ is a marginal probability.

To avoid this, I enumerated the different values $$X$$ takes on and plugged it into the original quantity to solve -- $$P(X|Y=1)$$:

• $$P(X=0|Y=1) = 0.4/0.6 = 4/6$$
• $$P(X=1|Y=1) = 0.2/0.6 = 2/6$$

This gives me the final answer of $$P(X|Y=1) = [4/6, 2/6]$$, but I'm not sure whether the answer should be multiple probabilities or a single probability.

• P(X|Y=2) is a distribution in the same way that P(X) is also a distribution (and not just one "probability"). One probably is P(X=0, Y=0)=0.1, for example. – nbro Jan 28 at 2:14
• @nbro Does this mean my answer is correct? – Shrey Jan 28 at 4:04
• you're ok. just as $p(x,y)$ is a 2D function(table), $p(x)$, $p(x|Y=y)$ are 1D functions (rows). – gunes Jan 28 at 4:52
• $P(X|Y=1)$ is shorthand for $P(X=x|Y=1)$ – StatsStudent Jan 28 at 5:47

You have gone about this correctly, but the final answers are typically written as a function of $$x$$. It's helpful, I think, to remember that $$P(X|Y=1)$$ is just shorthand for $$P(X=x|Y=1)$$ where $$x$$ is any number in the support of $$x$$ (in this case 0 and 1). So you'd calculate this as follows:

$$\begin{eqnarray*} \\{P(X|Y=1)} & = & {P\left(X=x|Y=1\right)}\\ & = & \frac{P\left(X=x,\,Y=1\right)}{P\left(Y=1\right)}\\ & = & \frac{P\left(X=x,\,Y=1\right)}{P\left(X=0,\,Y=1\right)+P\left(X=1,\,Y=1\right)}\\ & = & \frac{P\left(X=x,\,Y=1\right)}{0.4+0.2}\\ & = & \frac{P\left(X=x,\,Y=1\right)}{0.6} \end{eqnarray*}$$

Now, writing this as a function of $$x$$ gives:

$$\begin{eqnarray*} P\left(X=x|Y=1\right) & = & \begin{cases} \frac{P\left(X=0,\,Y=1\right)}{0.6} & ,\text{for }x=0\\ \frac{P\left(X=1,\,Y=1\right)}{0.6} & ,\text{for }x=1 \end{cases}\\ & = & \begin{cases} \frac{0.4}{0.6} & ,\text{for }x=0\\ \frac{0.2}{0.6} & ,\text{for }x=1 \end{cases}\\ & = & \begin{cases} \frac{2}{3} & ,\text{for }x=0\\ \frac{1}{3} & ,\text{for }x=1 \end{cases} \end{eqnarray*}$$

You are correct. You are supposed to be getting "multiple" probabilities.

You said that your goal is to figure out $$P(X|Y = 1)$$. Well, in order to achieve your goal, you need to know what the probability that $$X = 0$$ given that $$Y = 1$$ is as well as what the probability that $$X = 1$$ given that $$Y = 1$$ is, which you did.

nbro's comment is basically telling you that when you get "multiple" probabilities, you are actually computing a probability mass (or density) function (or, equivalently, yet not the same, the distribution of the random variable $$X$$ given $$Y = 1$$).

Note: $$P(X|Y=1)=[4/6,2/6]$$ is the probability mass function of the random variable $$X$$ given $$Y = 1$$ because it tells you what that probability is for all the possible values of $$X$$, ie, $$X = 0$$ and $$X$$ = 1.

Finally, I use "multiple" in quotes because nobody really says that. In your case, they would ask something like: "This gives me the final answer of P(X|Y=1)=[4/6,2/6], but I'm not sure whether the answer should be $${\it \text{ a probability mass function}}$$ or a single probability."