Lorenzo
2010-11-18 13:19:05 UTC
Hello,
I must premit I am not a numerical analyst/Matlab expert so please forgive me if I do not express myself in the appropriate terms.
Few months ago I started working on a semi-analytical approximations to an expectation of a functional of a terminal SDE value (yes, financial maths). I tested them against a Monte Carlo benchmark built upon a Euler scheme for a particular SDE and arithmetic means of the path-ways terminal values. I used Matlab 2007, do not remember the version though. I came up with 3 different analytical formulas approximating the Monte Carlo simulation (100000 path samples) exactly to the second-third decimal point.
I have now changed to the 2010 Matlab version. Running the same .m files for the Monte Carlo simulati now yields a 0.04-0.1 error with the semi analytical approximation. In relative terms the new expectations have an average 1% error respect to the old ones, systematically. This makes me suspect the algorithm I am using combined with the 2010 randn algorithm introduces a bias.
I have tried the following:
1) Reseeding the stream, as explained in the math help, via
RandStream.setDefaultStream(s);
s = RandStream('mt19937ar','Seed', 5489);
after starting the session, at global level before the path simulations, after each path simulation, after each gaussian sample for the sde. The first had no effect, the latter three killed the randomness.
2) Defining the algorithm in both of the following ways.
2.1) Generating a global random matrix on which the SDE process operates.
2.2) Generating one normal sample for each mesh of the path of the process. No difference.
As a remark my original code implemented on my old 2007 version used the second ( I know it is not optimal) with no initial seeding for randn. I didn't even consider polishing it becuase results were already strikingly accurate and runtime was not an issue.
I would appreciate any help or suggestion. I know it is a bad thing to say I do not really know how random number generators work, I use them as a black box. I guess I am learning something from this situation.
Lorenzo
I must premit I am not a numerical analyst/Matlab expert so please forgive me if I do not express myself in the appropriate terms.
Few months ago I started working on a semi-analytical approximations to an expectation of a functional of a terminal SDE value (yes, financial maths). I tested them against a Monte Carlo benchmark built upon a Euler scheme for a particular SDE and arithmetic means of the path-ways terminal values. I used Matlab 2007, do not remember the version though. I came up with 3 different analytical formulas approximating the Monte Carlo simulation (100000 path samples) exactly to the second-third decimal point.
I have now changed to the 2010 Matlab version. Running the same .m files for the Monte Carlo simulati now yields a 0.04-0.1 error with the semi analytical approximation. In relative terms the new expectations have an average 1% error respect to the old ones, systematically. This makes me suspect the algorithm I am using combined with the 2010 randn algorithm introduces a bias.
I have tried the following:
1) Reseeding the stream, as explained in the math help, via
RandStream.setDefaultStream(s);
s = RandStream('mt19937ar','Seed', 5489);
after starting the session, at global level before the path simulations, after each path simulation, after each gaussian sample for the sde. The first had no effect, the latter three killed the randomness.
2) Defining the algorithm in both of the following ways.
2.1) Generating a global random matrix on which the SDE process operates.
2.2) Generating one normal sample for each mesh of the path of the process. No difference.
As a remark my original code implemented on my old 2007 version used the second ( I know it is not optimal) with no initial seeding for randn. I didn't even consider polishing it becuase results were already strikingly accurate and runtime was not an issue.
I would appreciate any help or suggestion. I know it is a bad thing to say I do not really know how random number generators work, I use them as a black box. I guess I am learning something from this situation.
Lorenzo