 MarkovChain - Maple Help

Finance

 MarkovChain
 create new finite-state Markov chain Calling Sequence MarkovChain(P, S, i, n) Parameters

 P - Matrix; transition matrix S - Vector; state space i - posint; initial state n - posint; number of states per year Description

 • The MarkovChain command creates a new finite state Markov chain.
 • The parameter P is the transition matrix; it must be a square matrix (see Matrix) of size $d$, where $d$ is the number of states in the Markov chain. The value ${P}_{i,j}$ defines the probability of moving from state $j$ to state $i$.
 • The parameter S is a vector containing values for all possible states of the process.
 • The parameter n is the number of states per year. This process can only be simulated with $m=nk$ time steps per year, where $k$ is a positive integer. Assume for example that $X$ is a finite state Markov chain with $3$ states per year. If we simulate the process $X$ on the interval $0..2$ with 12 time steps, then the state change can occur only at steps $2$, $4$, $6$, $8$, and $10$. Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$
 > $P≔⟨⟨0.5,0.5⟩|⟨0.2,0.8⟩⟩$
 ${P}{≔}\left[\begin{array}{cc}{0.5}& {0.2}\\ {0.5}& {0.8}\end{array}\right]$ (1)
 > $X≔\mathrm{MarkovChain}\left(P,⟨1.0,2.0⟩,1,5\right)$
 ${X}{≔}{\mathrm{_X0}}$ (2)
 > $\mathrm{SamplePath}\left(X\left(t\right),t=0..2,\mathrm{timesteps}=10,\mathrm{replications}=10\right)$
 $\begin{array}{c}\left[\begin{array}{ccccccccccc}{1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {1.}& {2.}& {2.}& {\dots }\\ {1.}& {1.}& {2.}& {2.}& {1.}& {1.}& {1.}& {1.}& {2.}& {2.}& {\dots }\\ {1.}& {1.}& {2.}& {2.}& {2.}& {2.}& {2.}& {2.}& {2.}& {1.}& {\dots }\\ {1.}& {2.}& {1.}& {1.}& {2.}& {2.}& {1.}& {1.}& {2.}& {2.}& {\dots }\\ {1.}& {2.}& {2.}& {2.}& {2.}& {2.}& {1.}& {2.}& {2.}& {2.}& {\dots }\\ {1.}& {1.}& {2.}& {2.}& {2.}& {2.}& {2.}& {2.}& {2.}& {2.}& {\dots }\\ {1.}& {2.}& {1.}& {2.}& {2.}& {1.}& {2.}& {2.}& {2.}& {1.}& {\dots }\\ {1.}& {1.}& {1.}& {1.}& {1.}& {2.}& {2.}& {2.}& {2.}& {2.}& {\dots }\\ {1.}& {2.}& {2.}& {1.}& {2.}& {2.}& {2.}& {2.}& {2.}& {2.}& {\dots }\\ {1.}& {2.}& {2.}& {2.}& {2.}& {1.}& {2.}& {2.}& {2.}& {2.}& {\dots }\end{array}\right]\\ \hfill {\text{10 × 11 Array}}\end{array}$ (3)

The following command will issue an error because the number of time steps used in simulation must be a multiple of the number of states per year.

 > $\mathrm{SamplePath}\left(X\left(t\right),t=0..2,\mathrm{timesteps}=12,\mathrm{replications}=10\right)$ Compatibility

 • The Finance[MarkovChain] command was introduced in Maple 15.