Simulating a Two-State Markov Volatility Process
Summary
The document considers a geometric Brownian motion whose volatility switches between two states, with exponential waiting times governing transitions in each direction. It presents two simulation approaches. For a discrete time step, draw a uniform random number and compare it with the no-transition probability, exp(−λΔt); switching occurs with probability 1 − exp(−λΔt). Alternatively, simulate alternating exponential holding times for the two states, then generate the asset path conditional on the resulting volatility schedule.
The first approach approximates transitions on a time grid, while the event-time approach locates switches directly and suggests aligning simulation steps closely with those times. The answers give no code validation or simulation results. A time-grid method can miss multiple transitions within one step, so its accuracy depends on step size; the event-time approach requires handling the state-specific waiting-time rates correctly. The discussion concerns simulation mechanics rather than estimating parameters or pricing a derivative.
Key ideas
- A two-state volatility process can switch according to state-dependent exponential waiting times.
- Over a time step, the probability of a switch is one minus the exponential no-switch probability.
- A uniform draw can decide whether a transition occurs on each discrete step.
- Alternatively, simulate state-specific holding times and build the volatility path from event times.
- A coarse time grid may fail to capture multiple transitions within a step.
Tags
Full text
# Jump diffusion simulation
# Jump diffusion simulation
I want to simulate a geometric Brownian motion and we assume that the volatility of the stock can take just two values $\sigma_1=0.2$ and $\sigma_2=0.8$. We also assume that the jumps up from lower volatility $\sigma_1$ to higher volatility $\sigma_2$ occur as a exponential process with rate $\lambda_1=2$. Likewise, the jumps down from volatility $\sigma_2$ to lower volatility $\sigma_1$ occur as an exponential process with rate $\lambda_2=4$. I know how to simulate a geometric Brownian motion but i can't understand how I simulate the volatility. I must compare a number from the exponential distribution with what on every step to decide if I will make a jump or not?
## Answer by Kermittfrog (score 1)
https://quant.stackexchange.com/a/59583
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
% do not flip state
endif
```
HTH?
NB: You might want to simulate a vector of uniforms, and then iterate over elements to get the state $1$ or $2$. From this, you may compose a vector of volatiltities per time step.
I assume you are using `Matlab` or `Octave`? If that's the case, vectorisation is king!
## Answer by Forgottenscience (score 0)
https://quant.stackexchange.com/a/59580
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$, alternating event-times $\tau_i$ from $\text{Exp}(\lambda_1)$ and $\text{Exp}(\lambda_2)$ until $\tau_i > T$. Conditional on these times, you then just simulate your GBM conditional on $\gamma_t$. To make your life easier, choose your step-size such that you get very close to all the event-times $\tau_i$ when simulating the GBM.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.