Serving the Quantitative Finance Community

 
User avatar
GreekMartingale
Topic Author
Posts: 0
Joined: March 22nd, 2007, 10:08 pm

Random Numbers

April 28th, 2007, 8:16 pm

Hello i am new to Monte Carlo, i want to generate uniformly distributed random numbers in (x,y) such that x^2+y^2<=1. Any ideas please?Thank you in advance
 
User avatar
quantmeh
Posts: 0
Joined: April 6th, 2007, 1:39 pm

Random Numbers

April 28th, 2007, 8:24 pm

impossible
 
User avatar
Skyhawk
Posts: 0
Joined: April 8th, 2003, 8:09 pm

Random Numbers

April 28th, 2007, 8:36 pm

Impossible? How about: Generate two independent random numbers, x and y, each uniformly distributedon [-1, 1]. Compute D = x^2 + y^2. If D <= 1, use the pair (x,y). Else, reject the pair and tryagain.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Random Numbers

April 28th, 2007, 8:46 pm

One common approach for this type of problem is rejection sampling -- generate your x and y, test the condition, if its true then use the numbers, if its false then generate another pair of x and y, repeat. You'll throw out about 21% of your pairs, which is not too bad. EDIT: skyhawk beat me to it. But I do see jawabean's point. The result will be uniform on the unit quarter circle, but NOT uniform in X and Y anymore.
Last edited by Traden4Alpha on April 27th, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
GreekMartingale
Topic Author
Posts: 0
Joined: March 22nd, 2007, 10:08 pm

Random Numbers

April 28th, 2007, 8:51 pm

To give an idea about my project i want to integrate a real function of two variables on that domain. I want to produce random vectors and then take Monte Carlo
 
User avatar
quantmeh
Posts: 0
Joined: April 6th, 2007, 1:39 pm

Random Numbers

April 28th, 2007, 9:21 pm

QuoteOriginally posted by: SkyhawkImpossible? How about: Generate two independent random numbers, x and y, each uniformly distributedon [-1, 1]. Compute D = x^2 + y^2. If D <= 1, use the pair (x,y). Else, reject the pair and tryagain.can u prove that x and y will end up being uniformly distributed after this?
 
User avatar
quantmeh
Posts: 0
Joined: April 6th, 2007, 1:39 pm

Random Numbers

April 28th, 2007, 9:35 pm

QuoteOriginally posted by: GreekMartingaleTo give an idea about my project i want to integrate a real function of two variables on that domain. I want to produce random vectors and then take Monte Carlomaybe if you could translate the thing into polar coordinates, then generate random polar coordinates? just a thought