<- function(P){
compute_stationary_distribution
= nrow(P)
s
rep(1, s) %*% solve(diag(s) - P + matrix(rep(1, s * s), ncol = s))
}
Stationary Distributions
Function to compute stationary distribution for finite state, irreducible transition matrix
Markov’s letters
= c("vowel", "consonant")
state_names
= rbind(
P c(0.128, 0.872),
c(0.663, 0.337)
)
= c(0.432, 0.568) pi_0
Marginal distributions if initial distribution is stationary distribution
plot_DTMC_marginal_bars(pi_0, P, state_names, last_time = 20)
Ehrenfest urn chain
= 3
M
= 0:M
state_names
= rbind(c(0, 1, 0, 0),
P c(1/3, 0, 2/3, 0),
c(0, 2/3, 0, 1/3),
c(0, 0, 1, 0)
)
Stationary distribution
= compute_stationary_distribution(P)
pi_s
# display in table
data.frame(state_names, t(pi_s)) |>
kbl(col.names = c("state", "stationary probability")) |>
kable_styling()
state | stationary probability |
---|---|
0 | 0.125 |
1 | 0.375 |
2 | 0.375 |
3 | 0.125 |
Marginal distributions if initial distribution is stationary distribution
plot_DTMC_marginal_bars(pi_s, P, state_names, last_time = 20)
Ping pong
= c("AB", "AC", "BC")
state_names
= rbind(c(0, .7, .3),
P c(.8, 0, .2),
c(.6, .4, 0)
)
Stationry distribution
= compute_stationary_distribution(P)
pi_s
# display in table
data.frame(state_names, t(pi_s)) |>
kbl(col.names = c("state", "stationary probability"), digits = 4) |>
kable_styling()
state | stationary probability |
---|---|
AB | 0.4220 |
AC | 0.3761 |
BC | 0.2018 |
Marginal distributions if initial distribution is stationary distribution
plot_DTMC_marginal_bars(pi_s, P, state_names, last_time = 20)