# conditional probability combining discrete and continous random variables

Let us define $Y$ a continuous random variable having density $f(y,\theta)$ and X a discrete random variable such that $X=\mathbf{1}_{ \{Y \in [a_{i-1}, a_{i}) \}}$ . I want to compute the conditional density of Y given X. So I write $f_{Y}(y \mid X=x)= \frac{f_{Y X} (y,x)}{f_{X}(x)}$. Since I have 2 different types of random variables (discrete and continous) I have $f_{Y X} (y,x)= P(X=x \mid Y=y) f(Y=y)$. The problem is that I am familiar with computing the conditional probability of two random variables having the same type but in the mixed case I do not know how to proceed to compute $P(X=x \mid Y=y)$. Can someone help me?

• Why did you delete your previous question this one duplicates?
– Did
Jun 20 '15 at 20:05
• Compare "I want to compute the conditional density of Y given X" vs "I do not know how to proceed to compute P(X=x∣Y=y)". How is the latter useful to the former?
– Did
Jun 20 '15 at 20:06
• I deleted the previous question because it was not so precise. Jun 20 '15 at 20:08
• Hence putting to the garbage the suggestions made to you. When a question is "not so precise", the decent modus operandi is to modify it, not to erase one's footsteps.
– Did
Jun 20 '15 at 20:11
• I am sorry for any inconvenience :) Jun 20 '15 at 20:12

The condition that $Y=y$ just means we can substitute $y$ into $Y$. First lets consider the case where $x=1$. Our distribution will now be:$$P(X=1|Y=y) = \begin{cases} 1 &y\in [a_{t-1}, a_t) \\ 0 & \text{otherwise}\end{cases}$$Next consider $x=0$:$$P(X=0|Y=y) = \begin{cases} 0 &y\in [a_{t-1}, a_t) \\ 1 & \text{otherwise}\end{cases}$$Notice how to top case is always $x$ while the bottom case is $x'$ such that $x+x'=1$. This implies that $x'=1-x$. We can use this to combine both probabilities neatly:$$P(X=x|Y=y) = \begin{cases} x &y\in [a_{t-1}, a_t) \\ 1-x & \text{otherwise}\end{cases}$$

Edit: We build upon the process to find $f_Y(y|X=x)$.

We now can get the joint probability density:$$f_{X,Y}(x,y) = P(X=x|Y=y)f_Y(y) = \begin{cases} xf_Y(y) &y\in [a_{t-1}, a_t) \\ (1-x)f_Y(y) & \text{otherwise}\end{cases}$$Next we find $f_X(x)$ by integrating the joint probability density with respect to the $Y$ random variable. I integrate $f_{X,Y}(x,\gamma)$, because our result is constant with respect to the $y$ used elsewhere.$$p = \int\limits_{a_{t-1}}^{a_t} f_Y(\gamma)d\gamma \implies f_X(x) = xp + (1-x)(1-p)$$Finally we get:$$\begin{split} f_Y(y|X=x) = \frac{f_{X,Y}(x,y)}{f_X(x)} &= \begin{cases} \frac{xf_Y(y)}{xp + (1-x)(1-p)} &y\in [a_{t-1}, a_t) \\ \frac{(1-x)f_Y(y)}{xp + (1-x)(1-p)} & \text{otherwise}\end{cases} \\ &= \begin{cases} \frac{f_Y(y)}{p} &x=1\land y\in [a_{t-1}, a_t) \\ \frac{f_Y(y)}{1-p} & x=0\land y\notin [a_{t-1}, a_t) \\ 0 &\text{otherwise}\end{cases} \end{split}$$

• Granted, the question is badly written but it seems the OP's problem is to compute the conditional density of Y given X, not P(X=x∣Y=y) (well, who knows after all...).
– Did
Jun 20 '15 at 20:15
• I think I explained why I need to compute P(X=x \mid Y=y) in the question because of the joint density. No? Jun 20 '15 at 20:21
• Except that P(X=x∣Y=y) is no use if one wants to compute the conditional density of Y given X. (On the contrary, using @ is useful for one's comment to be signalled to the user they are addressed to.)
– Did
Jun 20 '15 at 21:11
• "Build upon" as in "forget and start completely anew"?
– Did
Jun 21 '15 at 10:45
• The $P(X=x|Y=y)$ was used to find the joint probability distribution $f_{X,Y}(x,y)$, so it wasn't forgotten and I didn't start anew.
– Wio
Jun 22 '15 at 3:09