random number generation w/ normal distribution

Started by
3 comments, last by Matthew Doucette 16 years, 1 month ago
Looking for a random number generator that has NORMAL DISTRIBUTION. One way to approximate this is to take the average of three random numbers. (Two random numbers is not enough, as the distribution is not curved.) Is there a faster and/or more accurate way?

Matthew Doucette, Xona Games

Advertisement
What programming language are you using? Some programming languages or compilers have built in support for normal distributions. Others, like C++ have accessible add-on libraries like boost::random that supply normal distribution RNGs.
I'm using MSVC++... but I want to know the algorithms to program it myself. No add-ons if possible.

Matthew Doucette, Xona Games

You can try the Box-Muller transform.
Thanks for the insight!

My random number generator is fast enough that generating 3 random numbers and taking their average (my first solution above) is FASTER than the Box-Muller transform which requires 2 random numbers, a cosine or sine, and a natural logarithm.

I realize the Box-Muller transform is probably a closer approximation to normal distribution, so to each their own. But thanks for bringing this to my attention!

Matthew Doucette, Xona Games

This topic is closed to new replies.

Advertisement