Serving the Quantitative Finance Community

 
User avatar
costica
Topic Author
Posts: 0
Joined: March 5th, 2002, 11:33 pm

Matlab code for Quasi Monte Carlo

December 17th, 2002, 12:16 pm

Dear Forum,do you know any links to good Matlab code for Quasi Monte Carlo methods? Halton, Faure or Sobol would be nice...Thank's a lot,Costica.
 
User avatar
bayes
Posts: 2
Joined: November 3rd, 2002, 2:19 pm

Matlab code for Quasi Monte Carlo

December 17th, 2002, 1:27 pm

Here is the halton code I use (algorithm provided by Phelim Boyle, "Quasi Monte Carlo Methods in Finance").
Attachments
halton.zip
(814 Bytes) Downloaded 108 times
 
User avatar
Rutger
Posts: 0
Joined: October 10th, 2002, 11:36 am

Matlab code for Quasi Monte Carlo

December 19th, 2002, 8:26 am

Bayes,I fooled around with your halton code and it directly resulted in some questions...When generating say 100 number in say 50 dimensions the first "columns" seem quasi random as I guess they should, but when looking at higher dimensions the columns seem to converge to "the same" random numbers??Secondly when using the halton sequence in higher dimensions for example a QMC to calculate VaR on a non-linear portfolio, given a covariance matrix that is invertable, would you use each draw (row) from each dimension and make the numbers dependent through the covariance matrix?Are the dimensions quasi independent to begin with??Any thoughts on using low-discrepancy sequence appreciated!Rgds,Rutger
 
User avatar
grabben
Posts: 2
Joined: August 23rd, 2002, 12:47 pm

Matlab code for Quasi Monte Carlo

December 19th, 2002, 9:13 am

Sorry to barge in on the discussion, but Quasi Monte Carlo is one of my interestes, so I just can't help myself... Rutger. Quasi random (QR) sequences are not really random. Neither are pseudo random (PR) numbers, which are normally used as random numbers in the Monte Carlo method. However, PR-sequences are constructed to be serially uncorrelated. This is not the case with QR-sequences, which just try to be as uniformly distributed as possible. This is especially easy to observe in the Halton sequence. In a base-2 sequence, the first number is 0.5, i.e. smack in the middle. The next two numbers are 0.25 and 0.75. These are the best numbers you can find if you want to have a uniform distributed variable (and only want 3 numbers in one dimension). Also, the two last numbers are directly a function of the first random number, as they are choosen so that they are at a maximum distance from all the previous numbers (as well as the "border values" 0 and 1).In the base-3 sequence, the fist two numbers are 1/3 and 2/3. The following numbers are 1/9, 4/9, 7/9, 2/9, 5/9, and 8/9. These numbers are the best "random" numbers you can find if you only want to use 8 numbers in one dimension. If we were to use a base-4 sequence now, the numbers would be 0.25, 0.5 and 0.75. However, these are the same numbers as the first 3 numbers in the base-2 sequence. Not a good idea! This is the reason for using the n:th prime as the base for the n:th dimension, and the 3rd dimension is therefor a base-5 sequence. Now, note that the first n-1 numbers in any base-n sequence is simply i/n for i = 1,2,...,n-1. As the 49th and 50th primes are 227 and 229 respectively (both quite high bases, compared with the 100 random numbers you wanted to find, but also a quite small difference between the two...), its easy to see why <i>"at higher dimensions the columns seem to converge to ''the same'' random numbers"</i>. This is simply the way the Halton sequence works and is the main reason why this sequence is not a very good sequence to use for high dimensional problems. Also, if you use the Halton sequence, try to use b^x-1 numbers from the sequence (b = base, x = any integer), as this will make the drawings "complete" (using a couple of drawings more or less than b^x-1 will only make the distribution less uniform, however, the distribution is simply an equally spaced abscissa...).
Last edited by grabben on December 18th, 2002, 11:00 pm, edited 1 time in total.
 
User avatar
Silvershark
Posts: 0
Joined: November 10th, 2002, 2:27 pm

Matlab code for Quasi Monte Carlo

December 20th, 2002, 7:25 am

Has anyone tested Sobol for high dimensional problems?
 
User avatar
tgui
Posts: 0
Joined: January 9th, 2003, 9:10 pm

Matlab code for Quasi Monte Carlo

January 9th, 2003, 9:51 pm

You can find Matlab code for Sobol sequences at : http://www.maths.unsw.edu.au/ForStudent ... ct.shtmlIt is provided by the University of South Wales, Sydney, Australia.They translate into Matlab the well-known code by Press et alii. It is fairly easy to extend it to higher dimensions using the table of primitive polynomials given by P.Jäckel (Monte Carlo Methods in Finance).I am currently writing a quasi random Maple application including Sobol sequences. If you're interested, I'll let you know when it's finished.But Sobol is much more efficient in C++ !
 
User avatar
pcerutti
Posts: 1
Joined: July 14th, 2002, 3:00 am
Location: Milano (Italy)

Matlab code for Quasi Monte Carlo

January 10th, 2003, 7:05 am

Hi!I've seen at the link you suggested that some lectures are also available if you are a registered student. Are you?.Is it possible to have access to those lectures?You can reply me at my private email if you prefere.Thank you very much.Pierluigi
Last edited by pcerutti on January 9th, 2003, 11:00 pm, edited 1 time in total.
 
User avatar
grabben
Posts: 2
Joined: August 23rd, 2002, 12:47 pm

Matlab code for Quasi Monte Carlo

January 10th, 2003, 7:21 am

Matlab code for the van der Corput, Halton, Faure and Sobol sequences can be found at: http://www.mathematik.uni-kl.de/~junk/h ... .html.This implementation of the Sobol sequence demands however that you provide the function with the irreducible polynomials yourself.