Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Topic Author
Posts: 23029
Joined: July 16th, 2004, 7:38 am

Boost Random Number Library

September 1st, 2007, 8:17 am

Anyone with experience here?The nice thing about this is that we can compare oranges with oranges when benchmarking sets of numerical results. The library seems to be comprehensive and even has rand48() and lagged Fibonacci RNGs.Its use would mean less dependence on the rand() or RAND()??RNG
Last edited by Cuchulainn on August 31st, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
Dimathematician
Posts: 0
Joined: January 13th, 2007, 9:28 am

Boost Random Number Library

September 1st, 2007, 9:00 am

I'm using it, everything good. I like the possibility to reset my seed anytime, thus being able to reproducethe same random numbers. I also like, that I can for example use the number series from the MersenneTwister algorithm, which can be used to produce new seeds. The constructors for different RN-generators arequite good, e.g. you can use boost::uniform_real<> un(0.5,0.7) to produce a non-standard uniformly distrubutedrandom number.
 
User avatar
Cuchulainn
Topic Author
Posts: 23029
Joined: July 16th, 2004, 7:38 am

Boost Random Number Library

September 1st, 2007, 11:40 am

Sounds good, it certainly saves doing it yourself and searching on internet. And it is better than any developer can do since I assume that the writers are specialists in this kind of specialist field. Each to his own.Have you used yet the generators for the Poisson and exponential distributions? QuoteThe constructors for different RN-generators arequite good, e.g. you can use boost::uniform_real<> un(0.5,0.7) to produce a non-standard uniformly distrubutedrandom number. Nice, a translation of U(0,1).Is there an option to say how to create uniform numbers, or is there just one way under the 'cover' of the code (rand()???)
Last edited by Cuchulainn on August 31st, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
lballabio
Posts: 0
Joined: January 19th, 2004, 12:34 pm

Boost Random Number Library

September 1st, 2007, 1:36 pm

QuoteOriginally posted by: CuchulainnAnd it is better than any developer can do since I assume that the writers are specialists in this kind of specialist field.In fact, it is good enough that it has been included in TR1 and will likely be part of the next C++ standard.Then again, I've not used it (yet.)Luigi
 
User avatar
Dimathematician
Posts: 0
Joined: January 13th, 2007, 9:28 am

Boost Random Number Library

September 1st, 2007, 1:44 pm

Yap, I've used both, poisson and exponential. I don't know how to judge the quality, I haven't done anyspecific tests, except checking if mean and var are ok. You can specify how to generate a rv, there's notjust one way. Basically, you're specifying the underlying algorithm, like Mersenne-Twister, or some otherslike here
 
User avatar
Cuchulainn
Topic Author
Posts: 23029
Joined: July 16th, 2004, 7:38 am

Boost Random Number Library

September 1st, 2007, 2:50 pm

QuoteOriginally posted by: lballabioQuoteOriginally posted by: CuchulainnAnd it is better than any developer can do since I assume that the writers are specialists in this kind of specialist field.In fact, it is good enough that it has been included in TR1 and will likely be part of the next C++ standard.LuigiThat's good enough for me, it's good news. Then we can all use the same algorithms instead of 'home-brew'.
Last edited by Cuchulainn on August 31st, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
blondie
Posts: 0
Joined: June 11th, 2007, 1:34 pm

Boost Random Number Library

September 1st, 2007, 8:47 pm

QuoteOriginally posted by: CuchulainnAnyone with experience here?The nice thing about this is that we can compare oranges with oranges when benchmarking sets of numerical results. The library seems to be comprehensive and even has rand48() and lagged Fibonacci RNGs.Its use would mean less dependence on the rand() or RAND()??RNGAmong the people who contributed to this library, there are specialists of quantum and classical monte carlo simulations of lattice spin models in condensed matter/statistical physics. These approaches are very demanding in terms of rngs and since the Ferrenberg "affair" any new implementation has been considered with caution. As far as I know these guys I would trust it. The question of performance is something else. But better having true results 'slowly' than wrong ones pretty fast... although I know that 'you', QF people, really care about speed. I hope this helps.PS : here is the kind of tests one may apply to the rngs.PPS : in percentage, how much time do a QF code spend generating RNS? I wonder. [I mean generically, I guess there may be variations.] In cases of interest for me, the speed bottleneck is not in generating rns.PPPS : and of course, I use these generators for my own MC codes (integers and reals).
 
User avatar
Cuchulainn
Topic Author
Posts: 23029
Joined: July 16th, 2004, 7:38 am

Boost Random Number Library

September 2nd, 2007, 10:02 am

QuotePPS : in percentage, how much time do a QF code spend generating RNS? I wonder. [I mean generically, I guess there may be variations.] In cases of interest for me, the speed bottleneck is not in generating rns.If we take a simple 1-factor model and simulate it using Oiler method, then at each step we need to calculate drift, diffusion and an N(0,1) variate. Doing a bit of + and - and then we are done. So, I reckon between 30-40% of effort on the RNG partQuotePPPS : and of course, I use these generators for my own MC codes (integers and reals). At this stage, doing parallel C++ is the way to go I suppose because of all this new processing power. Do you use MPI and/or OpenMP?
Last edited by Cuchulainn on September 1st, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
blondie
Posts: 0
Joined: June 11th, 2007, 1:34 pm

Boost Random Number Library

September 2nd, 2007, 5:38 pm

QuoteOriginally posted by: CuchulainnQuotePPS : in percentage, how much time do a QF code spend generating RNS? I wonder. [I mean generically, I guess there may be variations.] In cases of interest for me, the speed bottleneck is not in generating rns.If we take a simple 1-factor model and simulate it using Oiler method, then at each step we need to calculate drift, diffusion and an N(0,1) variate. Doing a bit of + and - and then we are done. So, I reckon between 30-40% of effort on the RNG partI see. It's huge, at least compared to my standards.QuoteQuotePPPS : and of course, I use these generators for my own MC codes (integers and reals). At this stage, doing parallel C++ is the way to go I suppose because of all this new processing power. Do you use MPI and/or OpenMP?Actually, I did once coded an MPI version, which is now more or less obsolete because there are libraries doing that ; but for the problems I'm interested in, it happens that this is not necessary because I don't need large scale lattices but a lot of simulations for different parameters. Distributing or parallelizing is no longer of any benefit.
 
User avatar
Cuchulainn
Topic Author
Posts: 23029
Joined: July 16th, 2004, 7:38 am

Boost Random Number Library

September 3rd, 2007, 6:11 pm

Example, originally from sitmo, dankie vir alles
 
User avatar
quartz
Posts: 3
Joined: June 28th, 2005, 12:33 pm

Boost Random Number Library

September 5th, 2007, 11:22 am

QuoteAmong the people who contributed to this library, there are specialists of quantum and classical monte carlo simulations of lattice spin models in condensed matter/statistical physics. These approaches are very demanding in terms of rngs and since the Ferrenberg "affair" any new implementation has been considered with caution. As far as I know these guys I would trust it. Well, I would trust L'Ecuyer and Matsumoto himself even more, so hope that someday the WELL generator and parents also become standard. However neither MT nor WELL are optimal with respect to speed (vs effort ofcourse), so I expect even better stuff to show up soon; and hope the guys at boost are paying attention.Btw here's also the DieHarder test suite.