Brighton Webs Ltd.
statistical and data services for industry
Home
Index
Page

Non-Uniform Random Numbers

One method of generating non-uniform random numbers is based on based on transforming a standard continuous uniform distribution with a distributions inverse probability function:

r=g(u)

where r is the non uniform number, u is a uniformly distributed random number in the range zero to one and g is the inverse probability function.

However, some distributions such as the normal and gamma do not have an accessible inverse probability function.  Whilst it is possible to use the cumulative probability function in an iteration process to get the value of x which corresponds to the value of u, this needs a lot of computational power.  The method described below is based on the interpolation of a cumulative probability table.

The methodology is intended for the generation of large quantities of random numbers.  It works by performing a relatively small number of complex calculations (say, 1,000) for the compilation of the table and a large number of less complex ones to interpolate the table.

For continuous distributions (e.g. Normal, Gamma etc.), a three stage process is used:

Step 1

Generate a cumulative probability table where:

p=f(x)

The range of x values depends on the nature of the distribution.

Minimum min = -∞ min <> -∞
xmin g(0.001) g(0)
Maximum max = ∞ max <> ∞
xmax g(0.999) g(1)

If values of u are less than 0.001 or greater than 0.999, then the table can be extended during the sampling process.

If the distribution is highly skewed, it may be necessary to divide the range of x values into sections.

Step 2

Use a source of standard uniform random numbers to obtain values for u.  In many applications these can be in the range (0,1).  The actual range should suit the application.

Step 3

Determine the x value that corresponds to the value of u using some form of interpolation.  The simplest (and quickest) method is linear interpolation.  the use of more sophisticated techniques should be balanced against the computing resources used.

This is shown in graphic form below:

This methodology works for both truncated and non-truncated distributions.

Source Random numbers for Discrete Distributions

For discrete distributions (e.g. binomial) as similar process is used based on the rule that the random variable takes the value x when the random number r meets the condition:

This is illustrated in the graphic below:

For discrete distributions such as the Poisson where the value of the random variable has a theoretical maximum value of infinity, a similar methodology to that used for continuous distributions attempts to ensure that maximum values generated are consistent with the largest value output of the source of continuous random numbers

 

For more information: info@brighton-webs.co.uk