Random Numbers

Random Numbers

Whether you’re using C#, Visual Basic (VB.NET) or F#, Numerics.NET makes it easy to make use of random numbers in your .NET applications. Numerics.NET is a complete math, linear algebra and statistics package for the Microsoft .NET platform. Features specifically related to random numbers include:

  • Compatible with the .NET Framework’s System.Random.
  • Extended with many convenience functions.
  • Four generators, with varying quality, period and speed to suit your application.
  • Generate random samples from any distribution.
  • More than 30 discrete, continuous and multivariate probability distributions.
  • Generate sets of correlated random numbers from any set of distributions.
  • Shufflers and randomized enumerators
  • Faur� and Halton quasi-random sequences.

It is well known that the random number generator built into the .NET framework has some deficiencies. With the random number generators in Numerics.NET, you can generate high quality random numbers fast.

Random Number Classes

The classes that implement random numbers live in the Numerics.NET.Statistics.Random namespace.

Random Number Generators

See the Random Numbers section of the Statistics Library User’s Guide for detailed explanations.

  • ExtendedRandom Extends the functionality of the built-in System.Random.
  • MersenneTwister Represents a pseudo-random number generator based on the Mersenne Twister algorithm.
  • GfsrGenerator Represents a generalized feedback shift register pseudo-random number generator.
  • RanLux Represents a RanLux pseudo-random number generator.
  • RanLux24 Represents a RanLux 24bit pseudo-random number generator.
  • CorrelatedRandomNumberGenerator Represents a random number generator that produces correlated random variables.

Probability Distributions

The random number generators can generate random numbers from any distribution. The distribution objects themselves also have methods to generate random variates. The following distributions are available:

For more on these distributions see the sections on Continuous, Discrete, and Multivariate distributions in the Statistics Library User’s Guide for detailed explanations.

Random Numbers QuickStart Samples

Our library comes with a large number of QuickStart samples that help you to get started in minutes. The following samples illustrate how to use the random numbers:

Project Description View source
RandomNumberGenerators Illustrates the use of classes that implement pseudo-random number generators. C# VB.NET
NonUniformRandomNumbers Illustrates ways of obtaining random numbers from a non-uniform distribution. C# VB.NET
QuasiRandom Illustrates the use of quasi-random sequences in multi-dimensional numerical integration. C# VB.NET

Trial version

If you would like to evaluate Numerics.NET, you can download a free, fully functional 30-day trial version. In addition to the code samples discussed here, it includes about 70 other samples as well as complete documentation for the entire library.