Compute marginal density given conditional density Given a continuous random variable $X$ with conditional pdfs $$f_{X=x|Y=0}\qquad \text{and}\qquad f_{X=x|Y=1}$$ and the probability of a discrete random variable $Y$ as $P(Y=0)=0.1,P(Y=1)=0.9$, how can I compute the marginal density $f_X$? Is it perhaps $$0.1f_{X=x|Y=0}\qquad+\qquad0.9f_{X=x|Y=1}\qquad?$$ I have found some formulas but they don't apply to this case as there is one discrete and one continuous rv and also the joint density function is needed. Also, how can I compute the joint density function? All formulas I found needed one to compute the other.
 A: We know that for any event $E$:
$ \hspace{10pt} P(E) = P(E|Y=0)\cdot P(Y=0)+P(E|Y=1)\cdot P(Y=1) $
When $E$ is the event that $X\leq x$: 
$$P(X\leq x) = P(X\leq x|Y=0)\cdot P(Y=0)+P(X\leq x|Y=1)\cdot P(Y=1) $$
That is, in terms of the CDF:
$$F_X(x)=F_{X|Y=0}(x)\cdot P(Y=0) + F_{X|Y=1}(x)\cdot P(Y=1)$$
Differentiating wrt $x$ we obtain:
$$f_X(x)=f_{X|Y=0}(x)\cdot P(Y=0) + f_{X|Y=1}(x)\cdot P(Y=1)$$
So yes, you are right!
A: As your question about the marginal distribution has already been answered, I'll address the joint density question.
This one is a bit subtle, because $X$ is continuous while $Y$ is discrete, so $(X, Y)$ is neither continuous nor discrete.
The interpretation of a joint density in this case is a function $f_{X, Y}$ such that, for any interval $(a, b) \subseteq \mathbf{R}$ and subset $I \subseteq \{0, 1\}$, we have that
$$
\Pr(X \in (a, b), Y \in I)
= \int_a^b \sum_{y\in I} f_{X, Y}(x, y)\, \mathrm{d}x.
$$
(if you've seen any measure theory, this states that $f_{X, Y}$ is the density with respect to the product of the Lebesgue measure on $\mathbf{R}$ and counting measure on $\{0, 1\}$).
Thus, we can compute
\begin{align*}
\Pr(X \in (a, b), Y = 0)
&= \Pr(X \in (a, b)| Y = 0) \Pr(Y = 0) \\
&= \int_a^b \frac{1}{10} f_{X|Y=0}(x)\, \mathrm{d}x,
\end{align*}
and similarly
\begin{align*}
\Pr(X \in (a, b), Y = 1)
= \int_a^b \frac{9}{10} f_{X|Y=1}(x)\, \mathrm{d}x.
\end{align*}
Together, this allows us to write the joint density
$$
f_{X, Y}(x, y)
= \begin{cases}
\frac{1}{10} f_{X|Y=0}(x) & \text{if } y = 0, \\
\frac{9}{10} f_{X|Y=1}(x) & \text{if } y = 1.
\end{cases}
$$
