I've seen the recursive expected value approach to solving this problem but I am interested in how to solve this from a generating function perspective.
Let E be the expected number of rolls, and X the value of a given roll.
My current setup for the generating function is as follows. Each is a distinct sequence that could precede 6,6,5.
$\lnot (X = 6) = \frac 56x $
$(X = 6) \land \lnot(X = 6) = \frac {5}{36}x^2$
The problem I run into is this step. Assuming we get 6,6, there are 3 outcomes. We can get 5 and be done, we can get 1 through 4 and have to go again, or we can get 6, in which case we need another 5 to be done. I am not sure how to model this with the generating function. My current approach is this:
$(X = 6) \land (X = 6) \land \lnot(X = 6 \lor X= 5) = \frac {4}{216}x^3$
$(X = 6) \land (X = 6) \land (X= 5) = \frac {1}{216}x^3$
$(X = 6) \land (X = 6) \land (X= 6) = \frac {1}{216}x^3$
$(X= 5) = \frac {1}{6}x$
We thus have 2 different setups; either we got a 6, 6, and a non-6 or non-5 and have to start over till we get a 6,6,5, or we got 6 and have to roll until we get a 5:
$$\sum_{i = 0}^\infty (\frac 56x + \frac {5}{36}x^2 + \frac {4}{216}x^3)^i(\frac {1}{216}x^3) + \sum_{i = 0}^\infty(\frac{1}{216}x^3)^i(\frac 16x)$$
Is this correct? If not, how should I setup the generating function?
Additionally, generally speaking, how do I get the expected value from the generating function? That is, what are the next steps?
Why not just do a first step analysis using a Markovian approach ?
Let $a$ be the starting state, $b$ the state where we have just rolled a $6,$ and $c$ the state where we have just rolled two consecutive $6's$,then
With one toss from start, we either roll a $6$ with $Pr = \frac16$, or remain put with $Pr =\frac56$
Framing equations step by step, we get
$\displaylines{a = 1+b/6 +5a/6 \\b = 1+c/6 +5a/6,\\c = 1 + c/6 +4a/6 }$
[The last equation means that with one step either you are done, stay put, or revert]
Solve to get $a = 216$