每個隨機矩陣確實有一個平穩的分佈。由於P具有所有的行和= 1,所以 (P-1)具有行總和= 0 =>(P-1)*(1,...,1)總是給你零。所以排名(P-1)< = n-1,所以是轉置到P-1的排名。因此,存在q使得(t(P)-I)* q = 0 => t(P)q = q。
複雜的價值1 + 0i似乎對我來說是相當真實的。但是如果你只能得到複數值,即在i不是0之前的係數,那麼算法會在某個地方產生一個錯誤 - 它以數字方式解決問題,並且不一定總是成立。它產生多少個特徵值和矢量並不重要,重要的是它找到了特徵值1的正確特徵向量,這就是你所需要的。
確保您的固定分佈確實是您的極限分佈,否則在計算它時沒有意義。您可以嘗試通過將不同的向量與矩陣^ 1000相乘來找到它,但我不知道在您的情況下需要多少時間。
最後但並非最不重要的,這裏有一個例子:
# 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
我不認爲所有的正項保證矩陣是可逆的或具有一切積極,實特徵值。 (反例:兩列爲1的矩陣。) –
看來我需要使用基本的限制therom.That真的是我希望使用的最後一種方法。 – user3482913