Random number within a range based on a normal distribution

Posted by ConfusedAgain on Stack Overflow See other posts from Stack Overflow or by ConfusedAgain
Published on 2010-05-01T23:37:28Z Indexed on 2010/05/01 23:47 UTC
Read the original article Hit count: 260

I'm math challenged today :(

I want to generate random numbers with a range (n to m, eg 100 to 150), but instead of purely random I want the results to be based on the normal distribution.

By this I mean that in general I want the numbers "clustered" around 125.

I've found this random number package that seems to have a lot of what I need: http://beta.codeproject.com/KB/recipes/Random.aspx

It supports a variety of random generators (include mersiene twister) and can apply the generator to a distribution.

But I'm confused... if I use a normal distribution generator the random numbers are from roughly -6 to +8 (apparently the true range is float.min to float.max).

How do a scale that to my required range?

© Stack Overflow or respective owner

Related posts about random-number-generator