Random number generation in C++

C++ TR1 has code for generating random samples from normal, exponential, gamma, and Poisson distributions directly. Random number generation using C++ TR1 explains how to use this built-in functionality and now to bootstrap the built-in functions to generate samples from Cauchy, Student-t, Snedecor-F, and Weibull distributions.

However, if for some reason you cannot use TR1 and need stand-alone random number generation code in C++, you may use the class SimpleRNG. The source files are here: SimpleRNG.h, SimpleRNG.cpp.

The C++ implementation of SimpleRNG is based on the C# class by the same name explained in the Code Project article Simple Random Number Generation.

SimpleRNG can be used to generate random unsigned integers and double values with several statistical distributions:

Related links:

Distribution chart
Stand-alone numerical code

 

Home