= c("vowel", "consonant")
state_names
= rbind(
P c(0.1, 0.9),
c(0.7, 0.3)
)
Introduction to Markov Chains
Markov’s letters
Transition matrix
plot_transition_matrix(P, state_names)
Transition spinners
plot_transition_spinners(P)
State diagram
plot_state_diagram(P, state_names)
Joining with `by = join_by(prob)`
Ping pong
= c("AB", "AC", "BC")
state_names
= rbind(c(0, .7, .3),
P c(.8, 0, .2),
c(.6, .4, 0)
)
Transition matrix
plot_transition_matrix(P, state_names)
Transition spinners
plot_transition_spinners(P)
State diagram
plot_state_diagram(P, state_names)
Joining with `by = join_by(prob)`
Weather chain
= c("RR", "NR", "RN", "NN")
state_names
= rbind(c(.7, 0, .3, 0),
P c(.5, 0, .5, 0),
c(0, .4, 0, .6),
c(0, .2, 0, .8)
)
Transition matrix
plot_transition_matrix(P, state_names)
Transition spinners
plot_transition_spinners(P)
State diagram
plot_state_diagram(P, state_names)
Joining with `by = join_by(prob)`
Collector problem
= 6
C
= 0:C
state_names
= matrix(rep(0, (C + 1) ^ 2), nrow = (C + 1))
P + 1, C + 1] = 1
P[C
for (s in 0:(C - 1)) {
+ 1, (s + 1):(s + 2)] = c(s / C, 1 - s / C)
P[s }
Transition matrix
plot_transition_matrix(P, state_names)
Transition spinners
plot_transition_spinners(P)
Warning in `[[<-.factor`(`*tmp*`, n, value = "2/2"): invalid factor level, NA
generated
Warning in `[[<-.factor`(`*tmp*`, n, value = "2/2"): invalid factor level, NA
generated
State diagram
plot_state_diagram(P, state_names)
Joining with `by = join_by(prob)`
Ehrenfest urn chain
= 3
M
= 0:M
state_names
= rbind(c(0, 1, 0, 0),
Pc(1/3, 0, 2/3, 0),
c(0, 2/3, 0, 1/3),
c(0, 0, 1, 0)
)
Transition matrix
plot_transition_matrix(P, state_names)
Transition spinners
plot_transition_spinners(P)
Warning in `[[<-.factor`(`*tmp*`, n, value = "2/2"): invalid factor level, NA
generated
Warning in `[[<-.factor`(`*tmp*`, n, value = "2/2"): invalid factor level, NA
generated
State diagram
plot_state_diagram(P, state_names)
Joining with `by = join_by(prob)`