隐马尔可夫模型中的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

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值