Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. P = (1/40)*matrix(c( 0, 20, 5, 5, 5, 5,
  2. 8, 0, 8, 8, 8, 8,
  3. 10, 0, 0, 10, 10, 10,
  4. 10, 0, 10, 0, 10, 10,
  5. 10, 0, 10, 10, 0, 10,
  6. 10, 0, 10, 10, 10, 0), nrow=6, byrow=T)
  7. P
  8. ## [,1] [,2] [,3] [,4] [,5] [,6]
  9. ## [1,] 0.00 0.5 0.125 0.125 0.125 0.125
  10. ## [2,] 0.20 0.0 0.200 0.200 0.200 0.200
  11. ## [3,] 0.25 0.0 0.000 0.250 0.250 0.250
  12. ## [4,] 0.25 0.0 0.250 0.000 0.250 0.250
  13. ## [5,] 0.25 0.0 0.250 0.250 0.000 0.250
  14. ## [6,] 0.25 0.0 0.250 0.250 0.250 0.000
  15.  
  16. g = eigen(t(P))$vectors[,1] # t=transpose for row (not column) eigenvector
  17. lim.dist = g/sum(g) # to make vector sum to 1
  18. lim.dist = as.numeric(lim.dist) # kill complex number notation
  19.  
  20. g
  21. ## [1] -0.4719292+0i -0.2359646+0i -0.4247363+0i -0.4247363+0i
  22. ## [5] -0.4247363+0i -0.4247363+0i
  23.  
  24. lim.dist
  25. ## 0.19607843 0.09803922 0.17647059 0.17647059 0.17647059 0.17647059
  26.  
  27. lim.dist %*% P # '%*%' denotes matrix multiplication in R
  28. ## [,1] [,2] [,3] [,4] [,5] [,6]
  29. ## 0.1960784 0.09803922 0.1764706 0.1764706 0.1764706 0.1764706
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement