[Math] What’s the expected number of coin tosses in order to get a sequence HHTTHH

probability

Assume you have a fair coin. What's the expected number of coin tosses in order to get a sequence HHTTHH? (H=head,T=tail).

Assuming you start tossing and keep going until your last six tosses match the sequence.

I want to know if there is a general formula for this kinds of problems?

Best Answer

The answer is $70=2^{\color{red}{6}}+2^{\color{red}{2}}+2^{\color{red}{1}}$. The integers $6$, $2$ and $1$ are the lengthes of the prefixes of the word HHTTHH that are also its suffixes, here HHTTHH, HH and H.

For more details, see some previous posts on the site about this exact model, or the book DNA, Words and Models by Robin, Rodolphe, and Schbath (2005), or the survey Enumeration of strings (1985) by A. Odlyzko (see section 4, citing the paper A combinatorial identity and its application to the problem concerning the first occurrences of a rare event (1966) by A. D. Solov’ev).