Palisade

Forum Navigation:


FORUMS > Technical Forum < refresh >
Topic Title: Matlab code for Quasi Monte Carlo
Created On Tue Dec 17, 02 01:16 PM
Topic View:

View thread in raw text format


costica
Junior Member

Posts: 12
Joined: Mar 2002

Tue Dec 17, 02 01:16 PM
User is offline

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.
 
Reply
   
Quote
   
Top
   
Bottom
     



bayes
Member

Posts: 80
Joined: Nov 2002

Tue Dec 17, 02 02:27 PM
User is offline

Here is the halton code I use (algorithm provided by Phelim Boyle, "Quasi Monte Carlo Methods in Finance").

halton.zip halton.zip  (1 KB)

 
Reply
   
Quote
   
Top
   
Bottom
     



Rutger
Junior Member

Posts: 15
Joined: Oct 2002

Thu Dec 19, 02 09:26 AM
User is offline View users profile

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

-------------------------
"If you torture the numbers long enough, they will confess..."
 
Reply
   
Quote
   
Top
   
Bottom
     



grabben
Member

Posts: 126
Joined: Aug 2002

Thu Dec 19, 02 10:13 AM
User is offline

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...).

-------------------------
There are three kinds of people: Those who can count, and those who can't.

Edited: Thu Dec 19, 02 at 12:55 PM by grabben
 
Reply
   
Quote
   
Top
   
Bottom
     



Silvershark
Member

Posts: 28
Joined: Nov 2002

Fri Dec 20, 02 08:25 AM
User is offline View users profile

Has anyone tested Sobol for high dimensional problems?

-------------------------
"VaR gets me to 95% confidence. I pay my risk managers good salaries to look after the remaining 5%."



- Dennis Weatherstone
 
Reply
   
Quote
   
Top
   
Bottom
     



tgui
Junior Member

Posts: 2
Joined: Jan 2003

Thu Jan 09, 03 10:51 PM
User is offline View users profile

You can find Matlab code for Sobol sequences at : http://www.maths.unsw.edu.au/ForStudents/courses/math3311/lect.shtml
It 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++ !
 
Reply
   
Quote
   
Top
   
Bottom
     



pcerutti
Senior Member

Posts: 238
Joined: Jul 2002

Fri Jan 10, 03 08:05 AM
User is offline

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

Edited: Fri Jan 10, 03 at 08:06 AM by pcerutti
 
Reply
   
Quote
   
Top
   
Bottom
     



grabben
Member

Posts: 126
Joined: Aug 2002

Fri Jan 10, 03 08:21 AM
User is offline

Matlab code for the van der Corput, Halton, Faure and Sobol sequences can be found at:
http://www.mathematik.uni-kl.de/~junk/highdim/sources.html.

This implementation of the Sobol sequence demands however that you provide the function with the irreducible polynomials yourself.

-------------------------
There are three kinds of people: Those who can count, and those who can't.
 
Reply
   
Quote
   
Top
   
Bottom
     

View thread in raw text format
FORUMS > Technical Forum < refresh >

Forum Navigation:

© All material, including contents and design, copyright Wilmott Electronic Media Limited - FuseTalk 4.01 © 1999-2010 FuseTalk Inc.