<s>[INST] problem requires condition probability Q. A robot fires 3 shots at a moving target. For the first shot, the probability of hitting the moving target is 1/3. For subsequent shots beyond the first shot, the probability of hitting the moving target is 1/2 if the previous shot is a hit (for example, the probability of hitting the moving target on the 3rd shot is 1/2 if the 2nd shot is a hit) and the probability of hitting the moving target is 1/4 if the previous shot is a miss. What is the mean and variance of the number of hits?
I understand that we can draw a probability tree diagram and find out the possibility of each case, but what i don't understand is how to calculate mean for the number of hits.
some kind of hint would be really helpful
 [/INST] Let $X$ be the number of hits. Then $X$ can take on values $0$, $1$, $2$, or $3$. 
We want to find the probability of $k$ hits, that is, $\Pr(X=k)$, for $k=0,1,2,3$.
To save space, write for example $hmm$ for hit then miss then miss.
The probability that $X=0$ is the probability of $mmm$. This is $\frac{2}{3}\cdot\frac{3}{4}\cdot\frac{3}{4}$, that is, $\frac{9}{24}$.
There are three ways we can have $1$ hit. They are $hmm$, $mhm$, and $mmh$.
The probabilities are $\frac{1}{3}\cdot\frac{1}{2}\cdot\frac{3}{4}$, $\frac{2}{3}\cdot \frac{1}{4}\cdot\frac{1}{2}$ and $\frac{2}{3}\cdot\frac{3}{4}\cdot\frac{1}{4}$. These add up to $\frac{8}{24}$.
The probability that $X=3$ is $\frac{1}{3}\cdot\frac{1}{2}\cdot\frac{1}{2}$, which is $\frac{2}{24}$.
We skipped $X=2$, because the probabilities must add up to $1$. So the probability that $X=2$ is $\frac{5}{24}$. It might be a good idea to find $\Pr(X=2)$ the long way, by listing cases, as a check.
In summary, $\Pr(X=0)=\frac{9}{24}$ and $\Pr(X=1)=\frac{8}{24}$ and $\Pr(X=2)=\frac{5}{24}$ and $\Pr(X=3)=\frac{2}{24}$.
Now finding the mean is simple:
$$E(X)=\frac{9}{24}\cdot 0+\frac{8}{24}\cdot 1+\frac{5}{24}\cdot 2+\frac{2}{24}\cdot 3.$$
For the variance, if is easiest to use the fact that $\text{Var}(X)=E(X^2)-(E(X))^2$. And we have
$$E(X^2)=\frac{9}{24}\cdot 0^2+\frac{8}{24}\cdot 1^2+\frac{5}{24}\cdot 2^2+\frac{2}{24}\cdot 3^2.$$
</s>