Problem: Suppose we flip a coin. Given two patternss of the same length composed of "Head" and "Tail", compute the probability of seeing the first string before the second one.
Solution: First-step Analysis.
Suppose the two strings are: HHTH, HHHT.
You have graph with states and transition probabilities in the Figure.
Define PH: The probability of seeing pattern HHTH before HHHT if we are currently at state H.
Similary, we can define PT, PHH, PHHH, PHHT, PHHHT, PHHTH.
Define P(H) and P(T) is the probability of emiting an H or a T. For a fair coin, we have P(H) = P(T) = 0.5.
Thus, we have the system of equations as follows:
PH = P(H)*PHH + P(T)*PT ---------(1)
(explanation: When you stand at state H, you have probability P(H) to go to the state HH, and probability P(T) to go to the state T)
PT = P(H)*PH + P(T)*PT ----------(2)
PHH = P(H)*PHHH + P(T)*PHHT -----------(3)
PHHH = P(H)*PHHH+P(T)*PHHHT -----------(4)
PHHT = P(H)*PHHTH+P(T)*PT ------------(5)
PHHHT = 0 ---------(6)
PHHTH = 1 ---------(7)
After plugging the equations (6) and (7) in the first 5 equations, you get five unknowns and 5 equations. Now you should be able to solve the system equations to get the value of these five unknowns. They are the probabilities of seeing the first pattern before the second one given the current state.
Thus, the probability of seeing pattern HHTH before the pattern HHHT is:
Porb{HHTH occur before HHHT} = P(H)*PH + P(T)*PT.

0 comments:
Post a Comment