I wanted to confirm if the theoretical form outlined below is inline with expectation for a model.
Say we have a coin that is tossed with probability $p$. We are interested in arriving at the pattern T,T,H after continuous tosses, and would like to determine the number of flips, denoted as $Z$ on average before arriving at our desired pattern. I've defined this as follows, conditioning on the path after the first tail $Y$ appears.
$E[Z] = E[Z|Y,t,h](1-p)(p) + E[Z|Y,h,t](p) + E[Z|Y,t,t](1-p)^2$
where
$ \ \ \ E[Z|Y,t,h] = Y + 2$
$ \ \ \ E[Z|Y,h,t] = Y + 1 + E[Z]$
$ \ \ \ E[Z|Y,h,h] = Y + 1 + E[Z]$
$ \ \ \ E[Z|Y,t,t] = Y + 2 + E[Z]$
Solving this for E[Z], however, does not yield the same as the simulated value. Any help in better understanding the error is much appreciated.