Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A = matrix(c(0.5, 0.5, 0,
- 0.5, 0, 0.5,
- 0, 0.5, 0.5), nrow = 3, byrow=T)
- A
- [,1] [,2] [,3]
- [1,] 0.5 0.5 0.0
- [2,] 0.5 0.0 0.5
- [3,] 0.0 0.5 0.5
- A2 = A %*% A; A2
- [,1] [,2] [,3]
- [1,] 0.50 0.25 0.25
- [2,] 0.25 0.50 0.25
- [3,] 0.25 0.25 0.50
- g = eigen(t(A))
- sg = as.numeric(g$vec[,1])
- # 1st col of vector output is vector you want
- # 'as.numeric' gets rid of complex-nr notation
- sg = sg/sum(sg) # scale so elements add to 1
- sg
- [1] 0.3333333 0.3333333 0.3333333
- g %*% A # check
- [,1] [,2] [,3]
- [1,] 0.3333333 0.3333333 0.3333333
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement