I'd like to ask, whether I did this task correctly.
We have two r.v. $X,Y$. Firstly, $Y$ has Bernoulli distribution
$\mathbb{P} \left( Y=1\right)=a \; \; \mathbb{P} \left( Y=2\right)=1-a$
Moreover we know $\mathbb{E} X,Var X, \mathbb{E} (X|Y=2), Var(X|Y=2)$. We want to calculate $Var(X|Y=1)$.
My solution is (let's denote $Z=X-\mathbb{E}(X|Y)$)
$Var(X|Y=1) = \mathbb{E} \left( Z^2|Y=1 \right)=\frac{1}{\mathbb{P}(Y=1)} \mathbb{E} Z^2 \cdot \mathbf{1}_{\{ Y=1 \}} =\frac{1}{\mathbb{P}(Y=1)} \mathbb{E} Z^2 - \frac{1}{\mathbb{P}(Y=1)} \mathbb{E} Z^2 \cdot \mathbf{1}_{\{ Y=2 \}} = \frac{1}{\mathbb{P}(Y=1)} \mathbb{E}(\mathbb{E}(Z^2|Y)) - \frac{\mathbb{P}(Y=2)}{\mathbb{P}(Y=1)}Var(X|Y=2) = \frac{1}{\mathbb{P}(Y=1)} \mathbb{E}(Var(X|Y)) - \frac{\mathbb{P}(Y=2)}{\mathbb{P}(Y=1)}Var(X|Y=2)$
where
$\mathbb{E}(Var(X|Y)) = VarX - Var(\mathbb{E}(X|Y))$
Calculating $Var(\mathbb{E}(X|Y))$ :
$Var(\mathbb{E}(X|Y)) = \mathbb{E} \left( \mathbb{E}(X|Y)-\mathbb{E}X\right)^2 = \mathbb{E} \left( (E(X|Y=1)-EX)\cdot \textbf{1}_{\{ Y=1\}}+(E(X|Y=2)-EX)\cdot \textbf{1}_{\{ Y=2\}}\right)^2 = \mathbb{P}(Y=1) \cdot (E(X|Y=1)-EX)^2+\mathbb{P}(Y=2) \cdot (E(X|Y=2)-EX)^2$
Am I right?
Given your two random variables $X$ and $Y$, you know the following:
Hint: For $\mathbb{Var}(X|Y=1)$, you should know the formula $$ \mathbb{Var}(X) = \mathbb{E}[\mathbb{Var}(X|Y)] + \mathbb{Var}[\mathbb{E}(X|Y)] $$