Test Example
Closed this issue · 2 comments
Hello,
let be these functions:
smm = simpleMM ("ABCD" :: String) 2
smmBW = baumWelch smm (listToArray ("ABCDABCDABCDABCD" :: [Char])) 100
viterbi' hmm d = viterbi hmm (listToArray d)
listToArray d = listArray (1, fromIntegral $ length d) d
Some Tests:
(viterbi' smmBW "A") == ["B"]
True
(viterbi' smmBW "B") == ["C"]
False
(viterbi' smmBW "C") == ["D"]
False
(viterbi' smmBW "D") == ["A"]
False
I think, there is something I do not understand.
May you indicate me where is my mistake please ?
In fact, the HMM model should be the following and the above tests are always True:
hmm = HMM { states=['A' .. 'D']
, events=['A'..'D']
, initProbs = ip
, transMatrix = tm
, outMatrix = om
}
ip s
| s == 'A' = 0.25
| s == 'B' = 0.25
| s == 'C' = 0.25
| s == 'D' = 0.25
tm s1 s2
| s1== 'B' && s2=='A' = 1
| s1== 'C' && s2=='B' = 1
| s1== 'D' && s2=='C' = 1
| s1== 'A' && s2=='D' = 1
| otherwise = 0
om s e
| s=='B' && e=='A' = 1
| s=='C' && e=='B' = 1
| s=='D' && e=='C' = 1
| s=='A' && e=='D' = 1
| otherwise = 0
The BaumWelch learning part as I wrote it seems not to be right.
The documentation of HMM is clear enough. Many thanks for this great lib.