
# finds stationary probabilities of a Markov chain using matrix powers

nmaltfindpi <- function(p,k) {
   niters <- ceiling(log2(k))
   n <- nrow(p)
   prd <- diag(n)
   for (i in 1:niters) {
      prd <- prd %*% p
   }
   colSums(prd) / n
}
