Consider two friends, Alice and Bob, who live far apart from each
other and who talk together daily over the telephone about what
they did that day. Bob is only interested in three activities: walking
in the park, shopping, and cleaning his apartment. The choice of
what to do is determined exclusively by the weather on a given day.
Alice has no denite information about the weather where Bob lives,
but she knows general trends. Based on what Bob tells her he did
each day, Alice tries to guess what the weather must have been
like.
Alice believes that the weather operates as a discrete Markov chain.
There are two states, "Rainy" and "Sunny", but she cannot observe
them directly, that is, they are hidden from her. On each day, there
is a certain chance that Bob will perform one of the following
activities, depending on the weather: "walk", "shop", or "clean".
Since Bob tells Alice about his activities, those are the observations.
The entire system is that of a hidden Markov model (HMM).
Alice knows the general weather trends in the area, and what Bob
likes to do on average. In other words, the parameters of the HMM
are known. They can be written down in the Python programming
language:
states = ('Rainy', 'Sunny')
observations = ('walk', 'shop', 'clean')
start_probability = {'Rainy': 0.6, 'Sunny': 0.4}
transition_probability = {
'Rainy' : {'Rainy': 0.7, 'Sunny': 0.3},
'Sunny' : {'Rainy': 0.4, 'Sunny': 0.6},
}
emission_probability = {
'Rainy' : {'walk': 0.1, 'shop': 0.4, 'clean': 0.5},
'Sunny' : {'walk': 0.6, 'shop': 0.3, 'clean': 0.1},
}
In this piece of code, start_probability represents Alice's belief
about which state the HMM is in when Bob rst calls her (all she
knows is that it tends to be rainy on average). The particular
probability distribution used here is not the equilibrium one, which is
(given the transition probabilities) approximately {'Rainy': 0.57,