Normal Distribution Random Generator Available!

One of the libraries I’ve looked for, but couldn’t find (for free) is a random number generator for a normal distribution. Uniform distributions are great, but in many cases, you want to mimic natural phenomenon (like human height) that fall into a normal, non-uniform distribution.

I’m very pleased to announce the release of a library that has just that; a normally-distributed random number generator (for integers only). It builds on the back of Mersenne Twister, which is an awesome, efficient, free random number generator.

In the spirit of our analysis of the .NET built-in random generator, here’s what a sample distribution looks like (compared with a uniform distribution):

Our randomly generated normal distribution.

You can find more details on the Random Number Generators page. And yes, the distribution does match up to the expected normal distribution statistically (68% in the first standard deviation, 95% in the next, and 99% in the final one).

About Ashiq Alibhai, PMP

Ashiq has been coding C# since 2005. A desktop, web, and RIA application developer, he's touched ASP.NET MVC, ActiveRecord, Silverlight, NUnit, and all kinds of exciting .NET technologies. He started C# City in order to accelerate his .NET learning.
This entry was posted in Libraries, Silverlight, Web, Wndows Forms and tagged , . Bookmark the permalink.

One Response to Normal Distribution Random Generator Available!

  1. Reid Miller says:

    Thanks for the normal random generator code I’m glad someone has already done the heavy lifting here. I’d recommend droping the dictonary and using an array, and then updating your search for the correct probabilty bucket to a binary search over the array. Uses less memory and is much faster.

Leave a Reply

Your email address will not be published. Required fields are marked *