# Coin flips to select random variables, and the expected value

Suppose I flip a coin until I get the first head, say on the $i^{\mathrm{th}}$ flip. When that happens, I sample a random variable $x_i$ whose expected value is $\mu_i$. This process (flipping the coin and then sampling the random variable) is itself a random variable; is there enough information here to determine the expected value of this random variable?

There is enough information. If the coin lands on heads with probability $p$, the probability of selecting $x_i$ is $p(1-p)^{i-1}$, and by linearity of expectation we have the expectation of the overall random variable as $$\sum_{i=1}^\infty p(1-p)^{i-1}\mu_i$$
The probability of fliping $i-1$ tails followed by a head is $\left(\dfrac{1}{2}\right)^i$, at which point you'd expect outcome $\mu_i$ on average from the corresponding $x_i$. Overall:
$$\displaystyle E[X] = \sum_{i=1}^{\infty} \left(\dfrac{1}{2}\right)^i \cdot \mu_i$$