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} ]

  • 相关阅读:
    Java安全之JNDI注入
    Visual Studio 2019 升级16.8之后(升级.Net 5),RazorTagHelper任务意外失败
    .Net Core 3.1升级 .Net 5后出现代码错误 rzc generate exited with code 1.
    重走py 之路 ——普通操作与函数(三)
    重走py 之路 ——字典和集合(二)
    设计模式结(完结篇)
    重走py 之路 ——列表(一)
    RestfulApi 学习笔记——分页和排序(五)
    RestfulApi 学习笔记——查询与过滤还有搜索(五)
    Android开发 Error:The number of method references in a .dex file cannot exceed 64K.Android开发 Error:The number of method references in a .dex file cannot exceed 64K
  • 原文地址:https://www.cnblogs.com/TTyb/p/9717452.html
Copyright © 2011-2022 走看看