Description Usage Arguments Details Value References See Also Examples
This function simulates a discrete time Markov chain with transition matrix P, state space 0,1,..,n and and initial state i for nsteps transitions.
1 | MCSimulation(P,i,nsteps)
|
P |
the transition matrix. |
i |
the initial state. |
nsteps |
the number of transitions to be simulated. |
We assume that P is well defined transition matrix with rows summing to 1.
Returns the vector statehist containing the realisation of the chain for nsteps transitions.\
Jones, O.D., R. Maillardet, and A.P. Robinson. 2009. An Introduction to Scientific Programming and Simulation, Using R. Chapman And Hall/CRC.
1 2 3 |
Loading required package: MASS
Loading required package: lattice
[1] 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 0
[38] 1 0 0 0 1 2 3 3 3 2 3 3 2 3 3 2 1 0 0 1 0 1 0 1 0 1 2 3 2 3 2 1 0 1 2 2 3
[75] 2 3 3 2 3 3 2 3 3 3 3 2 3 3 2 3 2 3 2 1 0 0 0 0 1 0 1 2 3 2 3 2 2 1 0 1 0
[112] 1 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 0 1
[149] 0 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 1 2 3 2 2 3 2 2 3 3 3 3 3 2 3 2 3 3 2
[186] 2 3 2 3 2 3 2 3 2 1 0 1 2 3 2 3 2 3 2 3 2 1 0 0 0 0 1 2 3 2 3 2 3 2 3 3 2
[223] 1 0 1 0 1 0 0 1 2 3 3 3 2 3 2 3 2 3 2 3 3 2 3 3 2 3 3 2 3
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.