I'm stuck on the following problem:
Suppose we want to compute the expectation of X (number of failures until first success) ~ Geom(p).
We can introduce an event A – first trial was success.
Then, according to my textbook: $EX$ = $E(X|A)P(A) + E(X|A^c)P(A^c) = 0p + (1+EX)q$.
However, In my understanding $E(X|A) = \frac{E[XI_A]}{P(A)}$. So, $EX$ = $\frac{E[XI_A]}{P(A)}P(A) +\frac{E[XI_{A^c}]}{P(A^c)}P(A^c) = 0p + (EX+1)$.
I don't get where this $q$ multiplier appeared from.
Could you please explain me that?
Let's describe what each of the terms in the law of total expectation represents.
$\operatorname{E}[X \mid A]$ is the expected number of failures observed, given that the first trial is successful. If the first trial is successful, that means no failures were observed, hence $X = 0$ is the only outcome and the expectation is $0$. When you write $\operatorname{E}[X \mathbb 1_A]$, you are constructing another random variable $$X \mathbb 1_A = \begin{cases}X, & A \text{ occurs} \\ 0, & A \text{ does not occur}.\end{cases}$$ But as I have already pointed out, if $A$ occurs, that means the very first trial was successful, hence $X = 0$, so we have $X \mathbb 1_A = 0$ in both cases.
$\Pr[A]$ is simply the probability that the first trial is successful. Since trials are independent and identically distributed Bernoulli random variables with probability of success $p$, we simply have $\Pr[A] = p$.
$\operatorname{E}[X \mid A^c]$ is the expected number of failures observed, given the first trial was a failure. If the first trial fails, then we have observed $1$ failure, and all subsequent trials, being independent of what happened before, behave in the same way as if we had not performed the first trial. That is to say, the expected number of additional failures after the first failure is also $\operatorname{E}[X]$. Therefore, $\operatorname{E}[X \mid A^c] = 1 + \operatorname{E}[X]$.
$\Pr[A^c]$ is the probability that the first trial is a failure. This is $q = 1 - p$.
Your use of indicator functions unnecessarily complicates the solution and suggests an over-reliance on formulas and definitions. The expression $$X \mathbb 1_{A^c} = \begin{cases} X, & A^c \text{ occurs} \\ 0, & A^c \text{ does not occur} \end{cases}$$ does not provide any insight into how to evaluate the expectation. Your claim that $\operatorname{E}[X \mathbb 1_{A^c}] = 1 + \operatorname{E}[X]$ is incorrect, because according to the above, we must have $\operatorname{E}[X \mathbb 1_{A^c}] \le \operatorname{E}[X]$. This is because $X$ is a random variable with nonnegative support, so $0 \le X$ for all $X$, and $X \mathbb 1_{A^c} \le X$.