views:

1401

answers:

3

Hi,

I would like to know if in C++ standard libraries there is any gaussian distribution number generator, or if you have any code snippet to pass.

Thanks in advance.

+10  A: 

The standard library does not. Boost.Random does, however. I'd use that if I were you.

jalf
+6  A: 

The GNU Scientific Libraries has this feature. GSL - Gaussian Distribution

Matt Price
"will have" ?
jalf
Lol, I wrote that before I looked up the answer... I guess I should change it :)
Matt Price
+6  A: 

C++ Technical Report 1 adds support for random number generation. So if you're using a relatively recent compiler (visual c++ 2008 GCC 4.3), chances are that it is available out of the box.

See here for sample usage of std::tr1::normal_distribution (and many more).

Can
If it is not there yet, you can find it as part of Boost, too: http://www.boost.org/doc/libs/1_39_0/doc/html/boost_tr1/subject_list.html#boost_tr1.subject_list.random
stephan