• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Euler discretization for Monte Carlo Simulation

Joined
3/3/11
Messages
22
Points
11
I tried implementing the Euler discretization to approximate a stochastic process X that satisfies the stochastic differential equation. However, the result I got when compare with the standard Monte Carlo simulation is very far off so I assume I've made an error somewhere in this code. I'm implementing in Java and my Euler discretization equation is

for (int i = 0; i < n; i++) { //n is the no. of runs
for (int j = 0; j < m; j++) { //m is the no. of timesteps
X = X+mu*timestep + sigma*Math.sqrt(timestep)*random.nextGaussian();
}
}

Does anyone know whether I did it wrongly?
 
As I guess, may be you make a mistake in the expression of X: may be like this
X= X + mu*timestep + sigma*Math.sqrt(j)*random.nextGaussian();
, because as "timestep" is no use in this loop of "j" from 0 to m
 
No, the standard deviation is proportional to the sqrt of the timestep.

The problem is you only have one variable X and you sum all the runs. You need to record the result after each run and start with X at zero again.
 
Thanks for your suggestions, I've found out the problem. The standard equation is this:

X = X+mu*X*timestep + sigma*X*Math.sqrt(timestep)*random.nextGaussian();

X should be in ALL the terms, not just the first term. This is a standard Euler equation.
 
Back
Top