Normal Random Generator

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Normal Random Generator

Seb Venus
Has anyone given thought to using something other than boxmuller, centrallimit or InverseCumulativeNormal?


Get a free e-mail account with Hotmail. Sign-up now.
------------------------------------------------------------------------------


_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Luigi Ballabio

On Jun 1, 2010, at 7:43 PM, Seb Venus wrote:

> Has anyone given thought to using something other than boxmuller,  
> centrallimit or InverseCumulativeNormal?

Such as?

Luigi


------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Seb Venus
There are a lot of different generators, but an obvious candidate is the Ziggurat method, which has become a standard method in the Matlab library.
http://www.mathworks.com/company/newsletters/news_notes/clevescorner/spring01_cleve.html

It is far faster than many other pseudo generators. I have some code that I could provide if it would be useful.


> CC: [hidden email]
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Quantlib-users] Normal Random Generator
> Date: Tue, 1 Jun 2010 21:48:50 +0200
>
>
> On Jun 1, 2010, at 7:43 PM, Seb Venus wrote:
>
> > Has anyone given thought to using something other than boxmuller,
> > centrallimit or InverseCumulativeNormal?
>
> Such as?
>
> Luigi
>


Get a free e-mail account with Hotmail. Sign-up now.
------------------------------------------------------------------------------


_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Kakhkhor Abdijalilov
I will take a look. Please post your code here.

Looks like Ziggurat method can generate many distributions precisely
and very quickly, provided a good RNG is available.

On Tue, Jun 1, 2010 at 4:59 PM, Seb Venus <[hidden email]> wrote:

> There are a lot of different generators, but an obvious candidate is the
> Ziggurat method, which has become a standard method in the Matlab library.
> http://www.mathworks.com/company/newsletters/news_notes/clevescorner/spring01_cleve.html
>
> It is far faster than many other pseudo generators. I have some code that I
> could provide if it would be useful.
>
>
>> CC: [hidden email]
>> From: [hidden email]
>> To: [hidden email]
>> Subject: Re: [Quantlib-users] Normal Random Generator
>> Date: Tue, 1 Jun 2010 21:48:50 +0200
>>
>>
>> On Jun 1, 2010, at 7:43 PM, Seb Venus wrote:
>>
>> > Has anyone given thought to using something other than boxmuller,
>> > centrallimit or InverseCumulativeNormal?
>>
>> Such as?
>>
>> Luigi
>>
>
> ________________________________
> Get a free e-mail account with Hotmail. Sign-up now.
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Jon Davidson-2
I've used the Ziggurat method a bit. Its the matlab implementation for normal random numbers and you can get some C source code from Octave. There is a small issue with generating uniform random numbers, which are embedded in the normal random number calculation. They use a very simple modular arithmetic number generator. In my code I replaced this with a Mersenne twister genertor. The whole thing is still about 5 to 10 times faster than box-muller which I first noticed because my matlab black-scholes was working as fast a C version of black-scholes, which doesn't make sense. However, my own implementation was in java but was just a translation of the octave C code.

Hope this is useful.

Jonathan Davidson

--- On Wed, 2/6/10, Kakhkhor Abdijalilov <[hidden email]> wrote:

> From: Kakhkhor Abdijalilov <[hidden email]>
> Subject: Re: [Quantlib-users] Normal Random Generator
> To: [hidden email]
> Date: Wednesday, 2 June, 2010, 1:22
> I will take a look. Please post your
> code here.
>
> Looks like Ziggurat method can generate many distributions
> precisely
> and very quickly, provided a good RNG is available.
>
> On Tue, Jun 1, 2010 at 4:59 PM, Seb Venus <[hidden email]>
> wrote:
> > There are a lot of different generators, but an
> obvious candidate is the
> > Ziggurat method, which has become a standard method in
> the Matlab library.
> > http://www.mathworks.com/company/newsletters/news_notes/clevescorner/spring01_cleve.html
> >
> > It is far faster than many other pseudo generators. I
> have some code that I
> > could provide if it would be useful.
> >
> >
> >> CC: [hidden email]
> >> From: [hidden email]
> >> To: [hidden email]
> >> Subject: Re: [Quantlib-users] Normal Random
> Generator
> >> Date: Tue, 1 Jun 2010 21:48:50 +0200
> >>
> >>
> >> On Jun 1, 2010, at 7:43 PM, Seb Venus wrote:
> >>
> >> > Has anyone given thought to using something
> other than boxmuller,
> >> > centrallimit or InverseCumulativeNormal?
> >>
> >> Such as?
> >>
> >> Luigi
> >>
> >
> > ________________________________
> > Get a free e-mail account with Hotmail. Sign-up now.
> >
> ------------------------------------------------------------------------------
> >
> >
> > _______________________________________________
> > QuantLib-users mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
> >
> >
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


     

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Chris Kenyon-2
In reply to this post by Seb Venus
Ziggurat is elegant, but remember that it is a rejection sampling method, so if you need to keep track of the random numbers (or the # of them) that you are using (e.g. for variance reduction) then you may want the other methods for simplicity.

Rgds / Chris

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Luigi Ballabio
In reply to this post by Seb Venus
On Tue, 2010-06-01 at 21:59 +0000, Seb Venus wrote:
> There are a lot of different generators, but an obvious candidate is
> the Ziggurat method, which has become a standard method in the Matlab
> library.
> http://www.mathworks.com/company/newsletters/news_notes/clevescorner/spring01_cleve.html
>
> It is far faster than many other pseudo generators. I have some code
> that I could provide if it would be useful.

Sure, thanks.  From the paper, it seems nice.  I still have to figure
out if---being a rejection technique---it plays well with
low-discrepancy sequences.  But in any case, it will be useful to have
it in the toolkit.

Luigi



--

Dealing with failure is easy: work hard to improve. Success is also
easy to handle: you've solved the wrong problem. Work hard to improve.
-- Alan Perlis



------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Ferdinando M. Ametrano-3
On Thu, Jun 3, 2010 at 5:08 PM, Luigi Ballabio <[hidden email]> wrote:
> I still have to figure
> out if---being a rejection technique---it plays well with
> low-discrepancy sequences.

if you don't use _all_ variates in the exact order they are generated
by the low-discrepancy uniform RNG then you're scrambling the
low-discrepancy property.
As such a rejection technique doesn't play well with low-discrepancy sequences

ciao -- Nando

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Luigi Ballabio
On Thu, 2010-06-03 at 17:18 +0200, Ferdinando Ametrano wrote:
> if you don't use _all_ variates in the exact order they are generated
> by the low-discrepancy uniform RNG then you're scrambling the
> low-discrepancy property.
> As such a rejection technique doesn't play well with low-discrepancy sequences

Yes, I though as much.

Thanks,
        Luigi

--

Cogito ergo I'm right and you're wrong.
-- Blair Houghton



------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Seb Venus
Note that the algorithm in boxmullergaussianrng.hpp is not an implementation of Box-Muller; it is actually the Marsaglia Polar method.
The Polar is also a rejection-based sampling method.
I am going to paste the Ziggurat code once I have finished testing it (very soon).

> Subject: Re: [Quantlib-users] Normal Random Generator
> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]; [hidden email]
> Date: Thu, 3 Jun 2010 17:35:14 +0200
>
> On Thu, 2010-06-03 at 17:18 +0200, Ferdinando Ametrano wrote:
> > if you don't use _all_ variates in the exact order they are generated
> > by the low-discrepancy uniform RNG then you're scrambling the
> > low-discrepancy property.
> > As such a rejection technique doesn't play well with low-discrepancy sequences
>
> Yes, I though as much.
>
> Thanks,
> Luigi
>
> --
>
> Cogito ergo I'm right and you're wrong.
> -- Blair Houghton
>
>


Get a free e-mail account with Hotmail. Sign-up now.
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Normal Random Generator

Luigi Ballabio
On Thu, 2010-06-03 at 19:11 +0000, Seb Venus wrote:
> Note that the algorithm in boxmullergaussianrng.hpp is not an
> implementation of Box-Muller; it is actually the Marsaglia Polar
> method.
> The Polar is also a rejection-based sampling method.

True. We should add to the docs a warning to that effect.

Luigi


--

There are two ways of constructing a software design. One way is to
make it so simple that there are obviously no deficiencies. And the
other way is to make it so complicated that there are no obvious
deficiencies.
-- C. A. R. Hoare



------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users