Calculating $E[X|Y]$ for continuous $X$ and discrete $Y$ I'm struggling with the following exercise, which I have the solution to but don't understand. I would appreciate any help.
The exercise
Let $X$ a random variable with $f_X(x) = 2x$ if $x \in [0,1]$ and $0$ otherwise, and $Y$ a random variable that gets the value 1 with probability X and $0$ otherwise (first X is chosen and then Y according to the result). Find $E[X|Y]$.
The provided solution
$$
E[X|Y = 0] = \int_{0}^{1}\frac{2x(1-x)}{\int_{0}^{1}2x(1-x)dx}xdx = \frac{1}{2}
$$
$$
E[X|Y = 1] = \int_{0}^{1}\frac{2x\cdot x}{\int_{0}^{1}2x\cdot xdx}xdx = \frac{3}{4}
$$
So we get a random variable that gets the value $\frac{3}{4}$ with probability $\frac{2}{3}$ and the value $\frac{1}{2}$ with probability $\frac{1}{3}$
Question #1
I am trying to understand how $E[X|Y = 0]$ and $E[X|Y = 1]$ were calculated. I assume we use the following formula:
$$
E[X|Y=y] = \int_{\infty}^{\infty}xf_{X|Y=y}(x)dx
$$
and plug in Bayes for density:
$$
f_{X|Y=y}(x) = \frac{P(Y=y|X=x)f_X(x)}{P(Y=y)}
$$
Which means that:
$$
P(Y=0) = \int_{0}^{1}2x(1-x)dx
$$
Is that correct? If so, why is the last equation true (and the respective equation for $P(Y=1)$)?
Question #2
How did we come up with the probabilities for each value? ($\frac{3}{4}$ with probability $\frac{2}{3}$ and $\frac{1}{2}$ with probability $\frac{1}{3}$)
Thank you!
 A: In your provided solution I think there is an "$x$" missing, from the formula for the conditional expectation, there is an "$x$" multiplying to the density.
Your formula for the conditional expectation and density are correct. Your expression for computing $P(Y=0)$ is also correct. The reason is:
$$P(Y=0)=\int_0^1 P(Y=y,X=x)dx=\int_0^1 P(Y=0|X=x)f_X(x)dx = \int_0^1 (1-x)2xdx$$
The first equality is also known as "law of total probability" the second equality is just the definition of conditional expectation and the last is just taken from your exercise.
Computing the integral above we have
$$P(Y=0)=\int_0^1 (2x-2x^2)dx = (x^2 -\frac{2}{3}x^3 |_{x=0}^{x=1} = 1-\frac{2}{3} = \frac{1}{3}$$
and hence
$$P(Y=1)=1-\frac{1}{3}=\frac{2}{3}.$$
You know that conditional expectations (conditioned w.r.t. random variables) are again a random variable. $E[X|Y]$ is a random variable with two different values according to the value of $Y$, one has probability $1/3$ and the other $2/3$.
As an extra exercise and funny way to check, you can compute $E[X]=\int_0^1 2x^2dx = \frac{2}{3}$ and this should be the same as using the "tower property" for the conditional expectation, that is
$$E[X] = E[E[X|Y]] = E[X|Y=0]P(Y=0) + E[X|Y=1]P(Y=1) = \frac{1}{2}\frac{1}{3}+\frac{3}{4}\frac{2}{3} = \frac{1}{6}+\frac{1}{2} = \frac{2}{3}$$
A: The expectation when $Y=0$ is 
$$
\int_{0}^{1}x*\frac{f_{X,Y}(x,1)}{f_{Y}(1)}
$$
while we have
$$
f_{X,Y}(x,1)=2x^{2}, f_{X,Y}(x,0)=2x(1-x)
$$
Therefore we have
$$
f_{Y}(1)=\int^{1}_{0}f_{X,Y}(x,1)=\int^{1}_{0}2x^{2}=\frac{2}{3}
$$
and obviously
$$
\frac{f_{X,Y}(x,1)}{f_{Y}(1)}=\frac{2x^{2}}{\frac{2}{3}}=3x^{2}, E(X|Y=0)=\int^{1}_{0}x*3x^{2}=\frac{3}{4}
$$
I hope the other situation, which is analogous, should be clear to you based on this. 
