zoukankan      html  css  js  c++  java
  • 马尔科夫链

    为了预测天气,假设观察多次后,得到天气变化的概率存在如下转换:

    第一天 第二天 概率
    晴天 晴天 0.2
    晴天 阴天 0.3
    晴天 雨天 0.5
    阴天 晴天 0.1
    阴天 阴天 0.6
    阴天 雨天 0.3
    雨天 晴天 0.4
    雨天 阴天 0.5
    雨天 雨天 0.1

    那么转移概率矩阵为:

    [egin{matrix} & sunny & cloudy & raining \ sunny & 0.2 & 0.3 & 0.5 \ cloudy & 0.1 & 0.6 & 0.3 \ raining & 0.4 & 0.5 & 0.1 \ end{matrix} ]

    列代表的是第一天的状态
    行代表的是第二天的状态
    

    例如最右边一列代表:

    1. 第一天是晴天,第二天是雨天的概率为0.5
    2. 第一天是阴天,第二天是雨天的概率为0.3
    3. 第一天是雨天,第二天是雨天的概率为0.2

    那么问题来了,假设今天预测的天气如下,那么明天的天气是怎样子的:

    [egin{matrix} & sunny & cloudy & raining \ today & 0.6 & 0.2 & 0.2 \ tomorrow & ? & ? & ? \ end{matrix} ]

    计算如下矩阵相乘即可({1,3}x{3,3}={1,3}):

    $ egin{bmatrix} 0.6 & 0.2 & 0.2 end{bmatrix} $ X $ egin{bmatrix} 0.2 & 0.3 & 0.5 0.1 & 0.6 & 0.3 0.4 & 0.5 & 0.1 end{bmatrix} $

    = $ egin{bmatrix}0.6 imes0.2+0.2 imes0.1+0.2 imes0.4 & 0.6 imes0.3+0.2 imes0.6+0.2 imes0.5 & 0.6 imes0.5+0.2 imes0.3+0.2 imes0.1 end{bmatrix} $

    = $ egin{bmatrix} 0.22 & 0.4 & 0.38 end{bmatrix} $

    得到结果为:

    [egin{matrix} & sunny & cloudy & raining \ today & 0.6 & 0.2 & 0.2 \ tomorrow & 0.22 & 0.4 & 0.38 \ end{matrix} ]

    也可以用如下计算:

    [egin{matrix} & sunny & cloudy & raining \ sunny & 0.2 & 0.3 & 0.5 \ cloudy & 0.1 & 0.6 & 0.3 \ raining & 0.4 & 0.5 & 0.1 \ end{matrix} ]

    列代表的是第一天的状态
    行代表的是第二天的状态
    那么第三天的状态呢?
    

    $ egin{bmatrix} 0.2 & 0.3 & 0.5 0.1 & 0.6 & 0.3 0.4 & 0.5 & 0.1 end{bmatrix} $ X $ egin{bmatrix} 0.2 & 0.3 & 0.5 0.1 & 0.6 & 0.3 0.4 & 0.5 & 0.1 end{bmatrix} $

    = $ egin{bmatrix} 0.2 imes0.2+0.3 imes0.1+0.5 imes0.4 & 0.2 imes0.3+0.3 imes0.6+0.5 imes0.5 & 0.2 imes0.5+0.3 imes0.3+0.5 imes0.1 0.1 imes0.2+0.6 imes0.1+0.3 imes0.4 & 0.1 imes0.3+0.6 imes0.6+0.3 imes0.5 & 0.1 imes0.5+0.6 imes0.3+0.3 imes0.1 0.4 imes0.2+0.5 imes0.1+0.1 imes0.4 & 0.4 imes0.3+0.5 imes0.6+0.1 imes0.5 & 0.4 imes0.5+0.5 imes0.3+0.1 imes0.1 end{bmatrix} $

    = $ egin{bmatrix} 0.27 & 0.49 & 0.24 0.2 & 0.54 & 0.26 0.17 & 0.47 & 0.36 end{bmatrix} $

    [egin{matrix} & sunny & cloudy & raining & sunny & cloudy & raining\ sunny & 0.2 & 0.3 & 0.5 & 0.27 & 0.49 & 0.24\ cloudy & 0.1 & 0.6 & 0.3 & 0.2 & 0.54 & 0.26\ raining & 0.4 & 0.5 & 0.1 & 0.17 & 0.47 & 0.36\ end{matrix} ]

  • 相关阅读:
    2月8日
    2月7日
    2月6日
    2月5日
    事务
    synchronized关键字详解(二)
    synchronized关键字详解(一)
    java.sql.SQLException: Access denied for user 'somebody'@'localhost' (using password: YES)
    wex5 教程 之 图文讲解 wex5集成HTML5 视频播放器
    wex5 实战 加密与解密系列(1) DES算法引入与调用
  • 原文地址:https://www.cnblogs.com/TTyb/p/9717452.html
Copyright © 2011-2022 走看看