# Simulate Geometric Brownian Motion with stochastic drift

I want to simulate a GBM with its drift parameter follows some continuous time Markov chain.

For example,

\begin{align} dK & =\mu Kdt+\sigma K dW \end{align}

where $\mu$ follows continuous-time Markov chain (CTMC) with transition rate matrix {{-1,1},{1,-1}}.

Unfortunately, I do not have a clue to start with. I understand ContinuousMarkovProcess can produce CTMC with integer-state between 1 and n like

P = ContinuousMarkovProcess[1, {{-1, 1},{1, -1}})];
data = RandomFunction[P, {0, 10}]*0.2+0.3;
ListStepPlot[data] Since the jump between 1 and 2 cannot fulfil my requirement, I do some linear transformation to the data in the example. It is also simple to simulation GBM in Mathematica just like

data2 = RandomFunction[GeometricBrownianMotionProcess[0.5, .1, 2], {0, 5, .01}];
ListLinePlot[data2] However, the question is the combination of these to simulate a mix of 2 GBMs in one curve and the drift is shifting between 0.5 and 0.7 follow the process in the first graph in the example.

• Have you seen ContinuousMarkovProcess? – Feyre Sep 2 '16 at 14:30
• Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – user9660 Sep 2 '16 at 16:25
• What have you tried so far? If you can show code it is more likely that people can show a solution. – user9660 Sep 2 '16 at 16:25