Computer Generation of Statistical Distributions

by Richard Saucier


This document presents a collection of computer-generated statistical distributions which are useful for performing Monte Carlo simulations. The distributions are encapsulated into a C++ class, called Random, so that they can be used with any C++ program. The class currently contains

The class is designed to be flexible and extensible, and this is supported in two ways: (1) a function pointer is provided so that the user-programmer can specify an arbitrary probability density function, and (2) new distributions can easily be added by coding them directly into the class. The format of the documentation is designed to provide the practitioner of Monte Carlo simulations with a handy reference for generating statistical distributions. However, to be self-contained, various techniques for generating distributions are also discussed, as well as procedures for estimating distribution parameters from data. Since most of these distributions rely upon a good underlying uniform distribution of random numbers, several candidate generators are presented along with selection criteria and test results. Indeed, it is noted that one of the more popular generators (rand) is probably overused and under what conditions it should be avoided.

Sample Program

Here is a simple example of how the Random class can be used to generate 1000 normally-distributed, pseudo-random numbers:

#include <iostream.h>
#include "Random.h"                   // include the header file

void main( void )
   Random rv;                         // declare a random variate (using the UNIX process ID as seed)
   for ( int i = 0; i < 1000; i++ )
      cout << rv.normal()             // reference the normal distribution (using default parameters)
           << endl;

Obtaining the Source Code

The complete source code is contained in a single header file, Random.h. You merely need to include this file in your code to make use of the distributions; precompilation is not necessary.

Obtaining the Documentation

The complete PDF documentation (106 pages, 1.8 MB) is available here.