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