>

$\mathrm{with}\left(\mathrm{Finance}\right)\:$

Consider a regime switching process with 2 regimes. In the first regime, the process is a Brownian motion with zero drift and high volatility; in the second regime, the process behaves like a Brownian motion with hight drift and low volatility. The transition probabilities are: $0.5$ for moving to the second regime given that the process is in the first regime and $0.2$ for moving to the first regime given that the process is in the second regime. The process will have $2$ regimes per year, which means that the regimes can switch only at $t=0.5$, $t=1.0$, and $t=1.5$.
>

$P\u2254\u27e8\u27e80.5\,0.5\u27e9\u27e80.2\,0.8\u27e9\u27e9$

${P}{\u2254}\left[\begin{array}{cc}{0.5}& {0.2}\\ {0.5}& {0.8}\end{array}\right]$
 (1) 
>

$S\u2254\left[\mathrm{BrownianMotion}\left(0\,0\,2.0\right)\,\mathrm{BrownianMotion}\left(0\,0.5\,0.001\right)\right]\:$

>

$X\u2254\mathrm{RegimeSwitchingProcess}\left(P\,S\,1\,2\right)\:$

>

$\mathrm{PathPlot}\left(X\left(t\right)\,t=0..2\,\mathrm{timesteps}=20\,\mathrm{replications}=10\,\mathrm{gridlines}=\mathrm{true}\,\mathrm{thickness}=2\,\mathrm{axes}=\mathrm{BOXED}\,\mathrm{color}=\mathrm{red}..\mathrm{blue}\right)$

The second example is similar to the one above, but one of the processes is deterministic.
>

$P\u2254\u27e8\u27e80.5\,0.5\u27e9\u27e80.2\,0.8\u27e9\u27e9$

${P}{\u2254}\left[\begin{array}{cc}{0.5}& {0.2}\\ {0.5}& {0.8}\end{array}\right]$
 (2) 
>

$S\u2254\left[\mathrm{BrownianMotion}\left(0\,0\,2.0\right)\,0.5t\right]$

${S}{\u2254}\left[{\mathrm{\_X3}}{\,}{0.5}{}{t}\right]$
 (3) 
>

$X\u2254\mathrm{RegimeSwitchingProcess}\left(P\,S\,1\,2\,t\right)$

${X}{\u2254}{\mathrm{\_X4}}$
 (4) 
>

$\mathrm{PathPlot}\left(X\left(t\right)\,t=0..2\,\mathrm{timesteps}=20\,\mathrm{replications}=10\,\mathrm{thickness}=2\,\mathrm{axes}=\mathrm{BOXED}\,\mathrm{gridlines}=\mathrm{true}\,\mathrm{color}=\mathrm{red}..\mathrm{blue}\right)$
