Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. A = matrix(c(0.5, 0.5, 0,
  2. 0.5, 0, 0.5,
  3. 0, 0.5, 0.5), nrow = 3, byrow=T)
  4. A
  5. [,1] [,2] [,3]
  6. [1,] 0.5 0.5 0.0
  7. [2,] 0.5 0.0 0.5
  8. [3,] 0.0 0.5 0.5
  9.  
  10. A2 = A %*% A; A2
  11. [,1] [,2] [,3]
  12. [1,] 0.50 0.25 0.25
  13. [2,] 0.25 0.50 0.25
  14. [3,] 0.25 0.25 0.50
  15.  
  16. g = eigen(t(A))
  17. sg = as.numeric(g$vec[,1])
  18. # 1st col of vector output is vector you want
  19. # 'as.numeric' gets rid of complex-nr notation
  20. sg = sg/sum(sg) # scale so elements add to 1
  21. sg
  22. [1] 0.3333333 0.3333333 0.3333333
  23. g %*% A # check
  24. [,1] [,2] [,3]
  25. [1,] 0.3333333 0.3333333 0.3333333
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement