Description Usage Arguments Examples
Generate a random discrete markov sequence
1 | markov_seq(n = 100, tmat = rbind(1:3, 3:1, 2:0), init = 1)
|
n |
length of the sequence |
tmat |
a transition matrix |
init |
the initial state |
1 2 3 4 5 6 7 8 9 10 | m <- matrix(c(0.5, 0.3, 0.2,
0.2, 0.6, 0.2,
0.2, 0.3, 0.5), 3, byrow=TRUE)
set.seed(1)
ms <- markov_seq(n=1000, tmat=m)
colMeans(m)
prop.table(table(ms))
round(prop.table(table(head(ms, -1), tail(ms, -1), dnn=c("n", "n+1")), 1), 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.