Skip to content

Instantly share code, notes, and snippets.

@slwu89
Created August 8, 2019 02:04
Show Gist options
  • Save slwu89/04c8daf200cbd51191369a7b496af999 to your computer and use it in GitHub Desktop.
Save slwu89/04c8daf200cbd51191369a7b496af999 to your computer and use it in GitHub Desktop.
Melancholia I has a matrix on the wall. This finds its stationary distribution. (https://en.wikipedia.org/wiki/Melencolia_I)
xx <- matrix(c(16,3,2,13,5,10,11,8,9,6,7,12,4,15,14,1),nrow = 4,ncol = 4,byrow = T)
xxx <- xx/rowSums(xx)
xeig <- eigen(xxx)
xvecs <- xeig$vectors
lvecs <- MASS::ginv(xvecs)
pi_eq <- lvecs[1,]/sum(lvecs[1,])
pi_eq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment