Hidden Markov model: which coin did Jack throw?

Jack has two coins that look identical. The fair coin F shows head (0) or tail (1) at 50%; the cheat coin C shows head at 90% and tail at 10%. If he has just used the fair coin he picks it again with probability 0.9; if he has just used the cheat coin he keeps it with probability 0.8. After choosing a coin he throws it and only tells us the outcome. He repeats this many times, and we want to guess which coin he used at each throw. When e(0|C) is unknown, we also want to estimate it from the throws. Changing a parameter re-simulates with the same seed. Keys: → step, ← back, f run all, r reset, s re-simulate, m toggle parameter estimation.

1 Model

2 Observation x = a1…aL (0 = head, 1 = tail)

3 Throws, hidden coins and the posterior Pr{Zi = C | x}

0 = head 1 = tail F fair coin C cheat coin posterior Pr{Zi = C | x} (bar height; dashed line = 0.5) α̃(i,C) = Pr{Zi = C | a1..i}, forward pass only decoded ≠ truth

4 Scaled forward and backward values by position