STFC Website

part of UK Research & Innovation

Version 1.0.1

28th March 2013

FA14: Uniform distribution

This function generates uniformly distributed pseudo-random numbers. Random numbers are generated in the ranges \(0 < \xi < 1, -1 < \eta < 1\) and random integers in \(1 \le k \le N\) where \(N\) is specified by the user.

A multiplicative congruent method is used where a 31 bit generator word \(g\) is maintained. On each call to the subroutine \(g _n+1\) is updated to \(7 ^5 g _n \mathrm{mod} (2 ^{31} - 1)\); the initial value of \(g\) is 1. Depending upon the type of random number required the following are computed \(\xi = g _{n+1} /(2 ^{31} - 1)\); \(\eta = 2 \xi - 1\) or \(k = \mathrm{int.part}\{ \xi N\} +1\).

The subroutine also provides the facility for saving the current value of the generator word and for re-starting with any specified value.