I would like to create a function that accepts Double mean
, Double deviation
and returns a random number with a normal distribution.
Example: if I pass in 5.00 as the mean and 2.00 as the deviation, 68% of the time I will get a number between 3.00 and 7.00
My statistics is a little weak…. Anyone have an idea how I should approach this? My implementation will be C# 2.0 but feel free to answer in your language of choice as long as the math functions are standard.
I think this might actually be what I am looking for. Any help converting this to code?
Thanks in advance for your help.
See this CodeProject article: Simple Random Number Generation. The code is very short, and it generates samples from uniform, normal, and exponential distributions.
You might be interested in Math.NET, specifically the Numerics package.
Caveat: The numerics package targets .NET 3.5. You may need to use the Iridium package if you are targeting an earlier version...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With