# Generating sequences from HMM

I encountered this question in a textbook (source: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.721.2540&rep=rep1&type=pdf) and was trying to workout the solution for it. Was wondering for the last question, wouldn't the probability be 0?

My working:

START -> M1 -> M2 -> M3 -> M4 -> M5 -> M6 -> M7 -> END

Probability Vector [A, T, C, G]

M1 : [0.6, 0.4, 0, 0]

M2 : [0.6, 0.4, 0, 0]

M3 : [0.4, 0.4, 0.2, 0]

M4 : [0.6, 0.4, 0, 0]

M5 : [0.4, 0.6, 0, 0]

M6 : [1, 0, 0, 0]

M7 : [0, 0, 0, 1]

To generate CTAAAAG = 0 * 0.4 * 0.4 * 0.6 * 0.4 * 1 * 1 = 0

The parenthetical statement in the first bullet point says without corrections. In which case, if an unseen nucleotide has a probability of zero, the probability of the sequence is zero. If the unseen nucleotides had the probability of NaN, then the sequence has a probability of NaN, which is a more thorough solution.

The correction would be adding a small iota value to the probabilities to be non zero —fudging against the zero outcome you otherwise find, which may be the result of the training being too small. You have 5 training sequences, so the iota would be <1/5. Let's hypothetically assume that if you were to have picked a 6th MSA sequence it would have had the missing value, so you could set the iota at 1/6. The assumption that you may find that element were you to sample twice as many is more statistically sensible, so iota to 1/10.

I used the letter iota, which is common parlance for something small, but iota is a really bad in maths as it looks like a 1 with English handwriting or in print: you can call the fudge value anything.