简体   繁体   中英

stochastic matrix stationary distribution

I have a large right stochastic matrix(row sums to 1).size~20000x20000. How can I find the stationary distribution of it?

I tried to calculate the eigenvalues and vectors, and get complex eigenvalues, eg.1+0i(more than one).

And try to use the following method:

pi=u[I-P+U]^-1

while when I do the inversion with solve() I got the error message Error in solve.default(A):system is computationally singular: reciprocal condition number = 3.16663e-19

As far as I understand, the Perron–Frobenius theorem ensures that every stochastic matrix as a stationary probability vector pi that the largest absolute value of an eigenvalue is always 1, so pi=piP,and my matrix has all positive entries,I can get a uniq pi,am I correct? Or if there any method I can calculate the row vector pi?

  1. Every stochastic matrix indeed has a stationary distribution. Since P has all row sums = 1, (PI) has row sums = 0 => (PI)*(1, ...., 1) always gives you zero. So rank(PI) <= n-1, and so is rank of transpose to PI. Hence, there exists q such that (t(P)-I)*q = 0 => t(P)q = q.

  2. Complex value 1+0i seems to be quite real for me. But if you get only complex values, ie coefficient before i is not 0, then the algorithm produces an error somewhere -- it solves the problem numerically and does not have to be true all the time. Also it does not matter how many eigenvalues and vectors it produces, what matters is that it finds the right eigenvector for eigenvalue 1 and that's what you need.

  3. Make sure that your stationary distribution is indeed your limit distribution, otherwise there is no point in computing it. You could try to find it out by multiplying different vectors with your matrix^1000, but I don't know how much time it will take in your case.

  4. Last but not least, here is an example:


# 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM