Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Normal Distribution random number generator

Reply
Thread Tools

Normal Distribution random number generator

 
 
Tan Thuan Seah
Guest
Posts: n/a
 
      10-12-2004
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


 
Reply With Quote
 
 
 
 
Gary Labowitz
Guest
Posts: n/a
 
      10-12-2004
"Tan Thuan Seah" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
--
Gary


 
Reply With Quote
 
 
 
 
Kai-Uwe Bux
Guest
Posts: n/a
 
      10-12-2004
Tan Thuan Seah wrote:

> 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



 
Reply With Quote
 
Cy Edmunds
Guest
Posts: n/a
 
      10-13-2004
"Tan Thuan Seah" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.

--
Cy
http://home.rochester.rr.com/cyhome/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
how to generate random data for a normal distribution Yudan YI \(OSU\) C++ 5 02-25-2005 10:07 AM



Advertisments