Normal Distribution random number generator

T

Tan Thuan Seah

Hi all,

I am looking for a way to generate a random number given the variance of a
gaussian distribution(or normal distribution). The mean is 0 but the
variance will be a user input. Does C++ have any of this sort of generator
available? Or must I use some transformation to get a random number from a
standardised normal distribution and map it to my distribution? Any link and
references are welcome.

Thuan Seah
 
G

Gary Labowitz

Tan Thuan Seah said:
Hi all,

I am looking for a way to generate a random number given the variance of a
gaussian distribution(or normal distribution). The mean is 0 but the
variance will be a user input. Does C++ have any of this sort of generator
available? Or must I use some transformation to get a random number from a
standardised normal distribution and map it to my distribution? Any link and
references are welcome.

You can get a full implementation in Java from the Sun site (download their
SDK which includes source) or e-mail me and I'll send you the code.
It is relatively clean, and I think pretty easy to translate to C++. They
implement Knuth, ACP, Section 3.4.1 Algorithm C.
There may be other versions on the web.
 
K

Kai-Uwe Bux

Tan said:
Hi all,

I am looking for a way to generate a random number given the variance of
a
gaussian distribution(or normal distribution). The mean is 0 but the
variance will be a user input. Does C++ have any of this sort of generator
available? Or must I use some transformation to get a random number from a
standardised normal distribution and map it to my distribution? Any link
and references are welcome.

Check out the Boost libraries. It has an impressive set of high quality
random number generators for various distributions, including the normal
distribution. I think, mean and standard deviation can be specified but
default to 0 and 1.


Best

Kai-Uwe Bux
 
C

Cy Edmunds

Tan Thuan Seah said:
Hi all,

I am looking for a way to generate a random number given the variance of a
gaussian distribution(or normal distribution). The mean is 0 but the
variance will be a user input. Does C++ have any of this sort of generator
available? Or must I use some transformation to get a random number from a
standardised normal distribution and map it to my distribution? Any link and
references are welcome.

Thuan Seah

Follow my sig and look for UVS.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top