White Oak Intelligence Posted on May 31 • Originally published at whiteoakintel.com Markov Chain Coin Sequence: E[HH] vs E[HTH] Explained # algorithms # computerscience # interview # tutorial In This Article The Question The Intuition Trap Building the State Machine for HH Solving the System: E[HH] = 6 Building the State Machine for HTH Solving the System: E[HTH] = 10 Why Overlapping Patterns Change Everything Python Simulation: 100,000 Trials Business Application: Credit Migration & Web Ranking The Question You flip a fair coin — one with probability 1/2 of landing heads and 1/2 of landing tails — repeatedly, recording every result. What is the expected number of flips required until the sequence HH appears for the first time as consecutive results? What is the expected number of flips required until HTH appears for the first time? Both questions have the same surface structure: you want a specific consecutive pattern, and you want to know, on average, how many flips it takes to observe it. The coin is fair, the flips are independent, and the patterns are short. These seem like they should yield similar answers. They do not. HH takes exactly 6 flips on average. HTH takes exactly 10. The four-flip gap between those two answers is not a rounding artifact or a computational error — it is a precise consequence of the internal structure of each pattern, and deriving it rigorously is one of the cleanest demonstrations of absorbing Markov chain analysis you will encounter. This problem appears frequently in quantitative finance interviews — at firms like Jane Street, Citadel, and Two Sigma — precisely because it separates candidates who understand Markov structure from those who rely on heuristic reasoning. Getting the answer right, and being able to explain it, requires building a state machine, writing the system of first-step equations, and solving it algebraically. That is exactly what we will do. The Intuition Trap Before the formal derivation, it is worth e
LIVE
![Markov Chain Coin Sequence: E[HH] vs E[HTH] Explained](https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmp4buldzddfbxkykb4rp.png)