Random Number Generation
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Random Number Generation

  1. #1
    Join Date
    Jul 2008
    Posts
    17

    Random Number Generation

    Hello, I'm a physicist working on some numerical stuff. I need a good random number generator package that generates numbers from basic distributions (for my current application I just need uniform and gamma). The catch is I need something with an exceptionally long period because my application may call for very, very large quantities of random numbers (I would probably be doing on the order of thousands of runs with each run involving around a billion random numbers). The simplest, most user friendly thing I've found online is Newran. While it is nicely laid out and easy to install, it admits that its random number generation becomes suspicious around 100 million generations. The question is, what should I use? If there is something known as a "standard" in the C++ numerical community then that would be perfect because this library will probably be used to produce results that will be in an academic journal. Hence a well known library is preferable.
    I read that there is something called the Technical Report 1 (or something like that) for C++ which is going to extend the standard library and include lots of very good random number generators, and further it says that there are already implementations of it. In fact, it says that g++ 4 already includes this stuff! (this is the compiler I use, I'm working in Linux). Except I can't seem to find information on it with g++.
    I also tried a library called Boost which implements many of the recommended things from Technical Report 1, I played around with the website for a bit but I found the presentation much less clear than Newran and I'm not sure if its what I want or not.
    So, any suggestions?

    PS I'm in physics, not CS so installing libraries and getting things to link correctly is still a huge pain for me, so a library that is very easy to install/good installation instructions counts for a lot.

  2. #2
    Join Date
    Jan 2009
    Posts
    596

    Re: Random Number Generation

    I think the Mersenne twister algorithm from the boost library would serve you well. Specifically the mt19937 class.

    Take a look here http://www.boost.org/doc/libs/1_37_0...enerators.html and here http://en.wikipedia.org/wiki/Mersenne_twister for more info

  3. #3
    Join Date
    Jul 2008
    Posts
    17

    Re: Random Number Generation

    Hey, thanks for the post but right after I wrote this I got a hit on google I somehow missed before, which is the Gnu Scientific Library (GSL). I just got it installed (its very easy on Ubuntu systems, you can do it through apt-get) and it seems very convincing. I will read up on the Mersenne twister though. Thanks for your post!

  4. #4
    Join Date
    Jan 2009
    Posts
    596

    Re: Random Number Generation

    That's cool - I hadn't thought about the GSL. That has pretty much the same selection of generators as boost by the looks of it.

    Hope your project goes well.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center