HMMBase.jl icon indicating copy to clipboard operation
HMMBase.jl copied to clipboard

Improve documentation for novices

Open BioTurboNick opened this issue 2 years ago • 1 comments

I'm coming in relatively fresh to HMMs and I'm having trouble matching up terms I'm seeing in other work.

  1. "Emission matrix" doesn't appear in the documentation - I gather it can be provided in place of B, but the documentation doesn't show that or describe its form.

  2. The form the "Transition matrix" should take isn't explicitly documented.

I'd be happy to make a contribution here, once I understand them.

BioTurboNick avatar May 07 '22 13:05 BioTurboNick

Hi,

Here is an example with the Weather guessing game from Wikipedia.
Does that makes things clearer?

# K: number of states

# a[i] = probability of starting in i
# vector of length K
start_probability = [0.6, 0.4]

# A[i,j] = probability of going from i to j
# matrix of size KxK
transition_probability = [
    0.7 0.3; # i=1 (Rainy)
    0.4 0.6  # i=2 (Sunny)
]

# B[i] = probability distribution of the observations in state i
# vector of size K
# We can model an emission matrix with the discrete `Categorical` distribution:
emission_probability = [
    # [walk, shop, clean]
    Categorical([0.1, 0.4, 0.5]), # i=1 (Rainy)
    Categorical([0.6, 0.3, 0.1]), # i=2 (Sunny)
]

hmm = HMM(start_probability, transition_probability, emission_probability)

maxmouchet avatar May 15 '22 13:05 maxmouchet