fan_walk <- function(init_state, n_iter, P){
states <- colnames(P)
states_visited <- rep(NA, times = n_iter)
states_visited[1] <- init_state
for(r in 2:n_iter){
states_visited[r] <-
sample(states, size = 1,
prob = P[states_visited[r-1],])
}
props <- table(states_visited)[states]/n_iter
return(props)
}