隱馬爾可夫模型中的Viterbi算法的C++實現

執行結果:

obs = walk
    next_state = Rainy
        state = Rainy
            p = 0.07 = 0.1 * 0.7
            {prob, v_path, v_prob} = {0.042, Rainy, 0.042}
            {total, argmax, valmax} = {0.042, Rainy,Rainy, 0.042}
obs = walk
    next_state = Rainy
        state = Sunny
            p = 0.24 = 0.6 * 0.4
            {prob, v_path, v_prob} = {0.096, Sunny, 0.096}
            {total, argmax, valmax} = {0.138, Sunny,Rainy, 0.096}
obs = walk
    next_state = Sunny
        state = Rainy
            p = 0.03 = 0.1 * 0.3
            {prob, v_path, v_prob} = {0.018, Rainy, 0.018}
            {total, argmax, valmax} = {0.018, Rainy,Sunny, 0.018}
obs = walk
    next_state = Sunny
        state = Sunny
            p = 0.36 = 0.6 * 0.6
            {prob, v_path, v_prob} = {0.144, Sunny, 0.144}
            {total, argmax, valmax} = {0.162, Sunny,Sunny, 0.144}
obs = shop
    next_state = Rainy
        state = Rainy
            p = 0.28 = 0.4 * 0.7
            {prob, v_path, v_prob} = {0.03864, Sunny,Rainy, 0.02688}
            {total, argmax, valmax} = {0.03864, Sunny,Rainy,Rainy, 0.02688}
obs = shop
    next_state = Rainy
        state = Sunny
            p = 0.12 = 0.3 * 0.4
            {prob, v_path, v_prob} = {0.01944, Sunny,Sunny, 0.01728}
            {total, argmax, valmax} = {0.05808, Sunny,Rainy,Rainy, 0.02688}
obs = shop
    next_state = Sunny
        state = Rainy
            p = 0.12 = 0.4 * 0.3
            {prob, v_path, v_prob} = {0.01656, Sunny,Rainy, 0.01152}
            {total, argmax, valmax} = {0.01656, Sunny,Rainy,Sunny, 0.01152}
obs = shop
    next_state = Sunny
        state = Sunny
            p = 0.18 = 0.3 * 0.6
            {prob, v_path, v_prob} = {0.02916, Sunny,Sunny, 0.02592}
            {total, argmax, valmax} = {0.04572, Sunny,Sunny,Sunny, 0.02592}
obs = clean
    next_state = Rainy
        state = Rainy
            p = 0.35 = 0.5 * 0.7
            {prob, v_path, v_prob} = {0.020328, Sunny,Rainy,Rainy, 0.009408}
            {total, argmax, valmax} = {0.020328, Sunny,Rainy,Rainy,Rainy, 0.009408}
obs = clean
    next_state = Rainy
        state = Sunny
            p = 0.04 = 0.1 * 0.4
            {prob, v_path, v_prob} = {0.0018288, Sunny,Sunny,Sunny, 0.0010368}
            {total, argmax, valmax} = {0.0221568, Sunny,Rainy,Rainy,Rainy, 0.009408}
obs = clean
    next_state = Sunny
        state = Rainy
            p = 0.15 = 0.5 * 0.3
            {prob, v_path, v_prob} = {0.008712, Sunny,Rainy,Rainy, 0.004032}
            {total, argmax, valmax} = {0.008712, Sunny,Rainy,Rainy,Sunny, 0.004032}
obs = clean
    next_state = Sunny
        state = Sunny
            p = 0.06 = 0.1 * 0.6
            {prob, v_path, v_prob} = {0.0027432, Sunny,Sunny,Sunny, 0.0015552}
            {total, argmax, valmax} = {0.0114552, Sunny,Rainy,Rainy,Sunny, 0.004032}
0.033612
Sunny,Rainy,Rainy,Rainy
0.009408

 

參考文獻:

http://en.wikipedia.org/wiki/Viterbi_algorithm
http://hi.baidu.com/liqinghuisi/blog/item/a11cd4f54394f22fbc3109cf.html

發佈了31 篇原創文章 · 獲贊 26 · 訪問量 32萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章