Easy Handling Discrete Time Markov Chains
Provided any markovchain
object, it returns a sequence of
states coming from the underlying stationary distribution.
1 2  markovchainSequence(n, markovchain, t0 = sample(markovchain@states, 1),
include.t0 = FALSE, useRCpp = TRUE)

n 
Sample size 
markovchain 

t0 
The initial state 
include.t0 
Specify if the initial state shall be used 
useRCpp 
Boolean. Should RCpp fast implementation being used? Default is yes. 
A sequence of size n is sampled.
A Character Vector
Giorgio Spedicato
A First Course in Probability (8th Edition), Sheldon Ross, Prentice Hall 2010
1 2 3 4 5 6 7 8  # define the markovchain object
statesNames < c("a", "b", "c")
mcB < new("markovchain", states = statesNames,
transitionMatrix = matrix(c(0.2, 0.5, 0.3, 0, 0.2, 0.8, 0.1, 0.8, 0.1),
nrow = 3, byrow = TRUE, dimnames = list(statesNames, statesNames)))
# show the sequence
outs < markovchainSequence(n = 100, markovchain = mcB, t0 = "a")

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.