# Tag Info

Besides a couple of ways you might try to improve your code (which I will not do here); your jump check is not working correctly: In a time step $\Delta t$, the process will jump with probability $\approx exp(-\lambda \Delta t)$. Hence, you need to compare if (unifrnd(0,1) > exp(-lambda * dt)) % jump occured % flip state else % no jump occured % ...
Just use the definition of conditional probability. With $\gamma_t \in \{-1,1\}$ an indicator returning 1 if $\sigma = 0.8$ and -1 otherwise, and $x_{1:T}$ the path of the Brownian motion over the time-period $[1,T]$ you have $$p(x_{1:T}, \gamma_{1:T}) = p(x_{1:T} \vert \gamma_{1:T})p(\gamma_{1:T}).$$ In practice you just simulate, until time $T$, ...