# Calculate drift of Brownian Motion using Euler method

I am working on a project to approximate numerically the solution $$X_t$$ of a stochastic diﬀerential equation (SDE) using the Euler method. I have do to this for the Brownian motion with drift. I am asked to stimulate $$N$$ paths under both the P and Q measure on the interval $$[0,T]$$. The pseudo code is as follows:

for i to N-1

• calculate the drift as function of previous stock price ($$\mu$$)
• calculate the volatility as function of previous stock price ($$\sigma$$)
• draw innovation from standard normal distribution ($$\epsilon$$)
• $$S_{t+i} = S_t + \mu_t dt + \sigma_t \sqrt{dt } \epsilon_t$$. next

where $$dt$$ is defined as $$(T-0)/N$$.

My current code is as follows:

nr_runs = 1000; %number of simulation runs
N       = 1000; %compute N grid points
t0      = 0;
T       = 10;

dt      = (T - t0) / N;
x0      = 0; %starting point
x       = zeros(1000);
mu      = 0;
sigma   = zeros(1000);

for i = 1:N
sigma(i)   = sqrt(i*dt); %under P measure, variance equal to time
epsilon = normrnd(0,1);
if i == 1
x(i)    = x0 + mu*dt + sigma(i)* sqrt(dt)*epsilon;
else
x(i+1)  = x(i) + mu*dt + sigma(i)* sqrt(dt)*epsilon;
end
end

M = mean(x);


However, I know no idea how to calculate the drift ($$\mu$$) from the previous stock price. What is the formula?

Thank you! Any help is appreciated.

In arithmetic brownian, drift does not depend on the previous price, so it is simply $$\mu \Delta t$$ as you have done. It depends on the previous price in geometric brownian though. Let’s recall the GBM equation:

$$dS_t=\mu S_t dt +\sigma S_t dB_t$$

Discretising: $$\Delta S_t=\mu S_t \Delta t + \sigma S_t \sqrt{\Delta t} N[0,1]$$

$$S_{t+1}-S_t=\mu S_t \Delta t + \sigma S_t \sqrt{\Delta t} N[0,1]$$

$$S_{t+1}=S_t \left( 1+\mu \Delta t \right)+ \sigma S_t \sqrt{\Delta t} N[0,1]$$

The first term on the rhs is the drift.

Re-comment, simulation would take drift and vol as inputs. If you have not been given these then you will need to calibrate the parameters using historical stock (physical measure) or current derivative prices(risk neutral) data. For example, to calibrate the arithmetic brownian under the physical measure, the simplest approach would be as follows: take the stock historical prices, convert the prices into returns, e.g., just generate daily return as $$S_{t+1}-S_t$$ ($$\ln S_{t+1}/S_t$$ for GBM), calculate the mean and standard deviation of the returns, and these are your daily drift and sigma. Annualising them would give you the parameters you need. Of course there are more sophisticated estimation methods that you can google.

• Thank you for the reply! That makes it more clear. However, how can I calculate the empirical drift in that case? As it is the first step in the pseudo code. – Emily Oct 7 '18 at 12:47
• Please see discussion here: quant.stackexchange.com/questions/35194/… would be simpler for arithmetic brownian as you don’t need to use log! – Magic is in the chain Oct 7 '18 at 12:53