| Title: | Mathematics at DEC | 
| Moderator: | RUSURE::EDP | 
| Created: | Mon Feb 03 1986 | 
| Last Modified: | Fri Jun 06 1997 | 
| Last Successful Update: | Fri Jun 06 1997 | 
| Number of topics: | 2083 | 
| Total number of notes: | 14613 | 
    G'day all!  I and a friend are writing a simulation program, and we
    want to randomize a normal distribution.  What is the inverse
    cumulative function for the normal curve?  (In other words, we
    randomize a uniform variable between 0 and 1, feed it to the function,
    and get a normal variable as output.)
    
    Or would it just be easier to approximate and use a lookup table?
    
    Matt
| T.R | Title | User | Personal Name | Date | Lines | 
|---|---|---|---|---|---|
| 1933.1 | RUSURE::EDP | Always mount a scratch monkey. | Thu Feb 09 1995 15:49 | 8 | |
|     See topic 938.
    
    
    				-- edp
    
    
Public key fingerprint:  8e ad 63 61 ba 0c 26 86  32 0a 7d 28 db e7 6f 75
To find PGP, read note 2688.4 in Humane::IBMPC_Shareware.
 | |||||
| 1933.2 | But why two variables? | POLAR::WALSHM | Fri Feb 10 1995 09:52 | 4 | |
|     Thanks for the pointer.  I don't understand, though, why it's necessary
    to randomize two variables.  Is there no single-variable function that
    would accomplish the same end?
    								Matt
 | |||||
| 1933.3 | RTL::GILBERT | Fri Feb 10 1995 11:40 | 3 | ||
| The bulk of the computation _isn't_ in the creation of the two (uniform) random variables -- it's in the subsequent calculations, which are apparently simplified when expressed in terms of two random variables. | |||||
| 1933.4 | WRKSYS::ROTH | Geometry is the real life! | Sat Feb 11 1995 17:38 | 27 | |
|     Re .2
    It isn't necessary to generate two variables, but doing so gives
    an analytically simple way to generate a pair of normal variates
    for those two uniforms you generated.
    A much faster way to approach the problem is to use "rejection",
    where you generate a uniformly distributed point in two dimensions,
    and throw it away and try again if it lies outside your desired
    distribution function curve (as if on a piece of graph paper.)
    If you break the curve up in simple to approximate pieces, this can
    be *very* fast.  That's the idea behind fast library routines.
    The book Numerical Recipes discusses this a little, but I don't know
    if they have a really fast normal variate generator.
    Note that yet another way is to generate several uniform variates
    and just add them!  The n-fold convolution of the uniforms
    gives a (binomial) approximation to a Gaussian, or viewed another way,
    Gaussians arise because of processes where a bunch of other variates
    are implicitly added together.  If your uniform generator is fast,
    this is not half bad.
    The approximate distrubtion curve this gives is called a "unform B-spline".
    - Jim
 | |||||