Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 随机矩阵平稳分布_R_Matrix Inverse - Fatal编程技术网

R 随机矩阵平稳分布

R 随机矩阵平稳分布,r,matrix-inverse,R,Matrix Inverse,我有一个大的右随机矩阵(行和为1)。大小~20000x2000。我怎样才能找到它的平稳分布 我试图计算特征值和向量,得到复特征值,例如1+0i(不止一个) 并尝试使用以下方法: pi=u[I-p+u]^-1 当我用solve()进行反演时,我在solve中得到了错误消息error.default(A):系统在计算上是奇异的:倒数条件数=3.16663e-19 据我所知,Perron–Frobenius定理确保每个随机矩阵作为平稳概率向量pi,特征值的最大绝对值始终为1,因此pi=piP,并且我的

我有一个大的右随机矩阵(行和为1)。大小~20000x2000。我怎样才能找到它的平稳分布

我试图计算特征值和向量,得到复特征值,例如1+0i(不止一个)

并尝试使用以下方法:

pi=u[I-p+u]^-1

当我用
solve()
进行反演时,我在solve中得到了错误消息
error.default(A):系统在计算上是奇异的:倒数条件数=3.16663e-19

据我所知,Perron–Frobenius定理确保每个随机矩阵作为平稳概率向量pi,特征值的最大绝对值始终为1,因此pi=piP,并且我的矩阵有所有正项,我可以得到uniq pi,对吗? 或者如果有任何方法可以计算行向量pi

  • 每个随机矩阵都有一个平稳分布。由于P的所有行和均为1, (P-I)的行和=0=>(P-I)*(1,…,1)始终为零。所以秩(P-I)t(P)q=q

  • 复杂值1+0i对我来说似乎非常真实。但是如果你只得到复数值,也就是说,i之前的系数不是0,那么这个算法在某个地方会产生一个错误——它用数字来解决问题,并且不一定总是真的。另外,它产生多少特征值和向量并不重要,重要的是它为特征值1找到正确的特征向量,这就是你需要的

  • 确保平稳分布确实是极限分布,否则计算它就没有意义了。你可以用不同的向量乘以你的矩阵^1000来找出答案,但我不知道在你的情况下需要多少时间

  • 最后但并非最不重要的是,以下是一个示例:




  • 我不认为所有的正项都能保证矩阵是可逆的,或者具有所有的正实特征值。(反例:两列为1的矩阵)似乎我需要使用基本极限定理。这是我最不希望使用的方法。
    # first we need a function that calculates matrix^n
    mpot = function (A, p) {
      # calculates A^p (matrix multiplied p times with itself)
      # inputes: A - real-valued square matrix, p - natural number.  
      # output:  A^p
    
      B = A
      if (p>1) 
        for (i in 2:p) 
          B = B%*%A 
      return (B)
    }
    
    
    # example matrix
    P = matrix( nrow = 3, ncol = 3, byrow = T, 
                data = c(
                  0.1, 0.9, 0,   
                  0.4, 0,   0.6,
                  0,   1,   0
                )
    )
    
    
    # this converges to stationary distribution independent of start distribution
    t(mpot(P,1000)) %*% c(1/3, 1/3, 1/3)
    t(mpot(P,1000)) %*% c(1, 0, 0)
    
    # is it stationary? 
    xx = t(mpot(P,1000)) %*% c(1, 0, 0)
    t(P) %*% xx
    
    # find stationary distribution using eigenvalues
    eigen(t(P)) # here it is!
    eigen_vect = eigen(t(P))$vectors[,1]
    stat_dist = eigen_vect/sum(eigen_vect) # as there is subspace of them, 
                                           # but we need the one with sum = 1
    stat_dist