遍历马尔可夫链静态分布:求解方程

时间:2014-07-29 13:09:41

标签: matlab markov-chains markov stochastic-process

我试图求解一组方程来确定遍历马尔可夫矩阵的平稳分布。

即,矩阵是

P=[0   0   0   0.5 0   0.5;
   0.1 0.1 0   0.4 0   0.4;
   0   0.2 0.2 0.3 0   0.3;
   0   0   0.3 0.5 0   0.2;
   0   0   0   0.4 0.6 0;
   0   0   0   0   0.4 0.6];

和方程组是来自下面定理的方程

如何将上面的等式转换为有效的Matlab语法?

2 个答案:

答案 0 :(得分:4)

静态分布由特征向量给出,特征值为1。

>> [V D] = eig( P.' ); %// note the transpose .' - we are looking for the **left** EV
>> st = V(:,1).'; %//' the stationary distribution
st =
 0.0051    0.0509    0.2291    0.6110    0.5346    0.5346
>> D(1)
 1.0000

答案 1 :(得分:0)

这与@Shai的answer不同。

另一种实现方法是求解稳态的Pi * P = Pi方程,而忽略pi_j之和必须为1的要求(目前)。

一点矩阵代数...
DTMC Stationary Distribution

那么我们知道,如果没有“ sum to 1”的要求,Pi对此没有唯一的解决方案。 Pi必须位于(transpose(P)-I)的空空间中。 MATLAB擅长于此。之后的规范化将提供所需的结果(如@LuisMendo在评论中指出的)。

 P=[0   0   0   0.5 0   0.5;
   0.1 0.1 0   0.4 0   0.4;
   0   0.2 0.2 0.3 0   0.3;
   0   0   0.3 0.5 0   0.2;
   0   0   0   0.4 0.6 0;
   0   0   0   0   0.4 0.6];

I = eye(size(P));

Y = null(P'-I)
PI = Y./(sum(Y))

这很容易检查。

>> PI(:)'     % Force into row vector
ans =
    0.0026    0.0259    0.1166    0.3109    0.2720    0.2720

与25步过渡矩阵进行比较。

P5 = P*P*P*P*P;
P25 = P5*P5*P5*P5*P5;
>>P25 =
    0.0026    0.0259    0.1166    0.3109    0.2720    0.2720
    0.0026    0.0259    0.1166    0.3109    0.2720    0.2720
    0.0026    0.0259    0.1166    0.3109    0.2720    0.2720
    0.0026    0.0259    0.1166    0.3109    0.2720    0.2720
    0.0026    0.0259    0.1166    0.3109    0.2720    0.2720
    0.0026    0.0259    0.1166    0.3109    0.2720    0.2720