We roll a 6 sided fair dice until the number 3 is received. What is the expected value of the sum of the rolls?
What I've done:
I defined a random variable $X$ to count the rolls amount. $X\sim G\left(\dfrac{1}{6}\right)$ so we have $P(X=k)=\left(\dfrac{5}{6}\right)^{k-1}\cdot\dfrac{1}{6}$
Then I defined another random variable, $S$, as the rolls sum. Using the law of total expectation we get $ E\left(S \right) =\sum ^{k}_{i=1}E( S| X= i) \cdot P( X= i) $
Now we define $x_{1},x_{2},\ldots ,x_{k}$ as the result of the $k$-th roll.
We note that $S=x_{1}+x_{2}+\ldots +x_{k}$, so we get: $$E\left( S\right) =E\left( x_{1}+x_{2}+\ldots +x_{k}\right)$$
$$\Rightarrow E( S| X= i) =E( x_{1}+x_{2}+\ldots +x_{i}| X= i)$$
Using the linearity of expectation, it is equal to: $$E( x_{1}|X=i) + E( x_{2}|X=i) + ... + E( x_{i}|X=i)$$
Now for each $1\leq t\leq i$ we have $$ E( x_{t}|X=i)= \sum_{j=1}^{6} j \cdot \frac{P(x_t = j, X=k)}{P(X=k)} $$
So that would conclude as $$E( S| X= i) = \sum_{t=1}^{i} \left( \sum_{j=1}^{6} j \cdot \frac{P(x_t = j, X=i)}{P(X=i)} \right) $$
But I'm not quite sure how to calculate the numerator here. Would appriciate a hint.
Thanks!
Yet an other answer. Your approach works fine. Your variable $X$, the number of rolls, is in fact a stopping time, the time / the index of entering the set $\{3\}$. I will denote it by $T$ (to have the right letter $X$ free now for its standard use), and will denote by capitalized letters $X_1,X_2,X_3,\dots$ your i.i.d. variables denoted by their lower case cousins.
All you need to observe is the following. Conditioned by the event $T=N$, $N\ge 1$ natural number, "stopping in $N$", we have
Then, denoting by $S_N$ the sum of $X_1,X_2,\dots,X_N$ we compute the needed expected value (of the random variable $S_T$): $$ \begin{aligned} \Bbb E[S_T] &=\sum_{N\ge 1}\Bbb E[S_N|T=N]\cdot\Bbb P[T=N] \\ &=\sum_{N\ge 1}\frac 15\left(\frac56\right)^N \Big(\sum_{n<N}\Bbb E[X_n|T=N]\ +\ E[X_N|T=N]\Big) \\ &=\sum_{N\ge 1}\frac 15\left(\frac56\right)^N \Big(\color{maroon}{(N-1)\cdot\frac{18}5}+\color{blue}{3}\Big) \\ &=\color{maroon}{18}+\color{blue}{3}=\bbox[yellow]{21}\ . \end{aligned} $$ $\square$
Note (on the last sum): The sum over $\frac 15\left(\frac56\right)^N\cdot \color{blue}{3}$ is the probability to see at least once the $3$, times $\color{blue}{3}$, so it is $\color{blue}{3}$. In the remained sum, the maroon part, we start from $N=2$, and denoting by $M$ the value $M=N-2$ we have to compute $\frac 15\left(\frac56\right)^2\cdot \frac{18}5\sum_{N\ge 2}(N-1)\left(\frac 56\right)^{N-2}$ which is $\frac 12\sum_{M\ge 0}(M+1)p^M=\frac 12\left(\sum_{m\ge 0}p^m\right)'=\frac 1{2(1-p)^2}$, calculated in $p=5/6$. We get $\frac 1{2/36}=18$.