(FILECREATED " 4-Jun-86 11:03:15" {QV}<PEDERSEN>LISP>RANDOMVARS.;1 1580 changes to: (VARS RANDOMVARSCOMS) (FNS GAUSS-RV)) (* Copyright (c) 1986 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT RANDOMVARSCOMS) (RPAQQ RANDOMVARSCOMS ((FNS GAUSS-RV))) (DEFINEQ (GAUSS-RV [LAMBDA (MU SIGMA) (* jop: " 3-Jun-86 17:48") (* * Gaussian variates ala BOX-MUELLER) (SETQ MU (FLOAT (OR MU 0.0))) (SETQ SIGMA (FLOAT (OR SIGMA 1.0))) (if (LEQ SIGMA 0.0) then (ERROR "SIGMA must be positive" SIGMA)) (FPLUS MU (FTIMES SIGMA (LET [(STORE (QUOTE (NIL] (if (CAR STORE) then (PROG1 (CAR STORE) (RPLACA STORE NIL)) else (LET ((TWOPI (CONSTANT (FTIMES 2.0 \IEEE.SHORT.PI))) (R1 (RAND 0.0 1.0)) (R2 (RAND 0.0 1.0)) ALPHA BETA) [SETQ ALPHA (SQRT (FTIMES -2.0 (LOG R1] (SETQ BETA (FTIMES TWOPI R2)) (RPLACA STORE (FTIMES ALPHA (COS BETA T))) (FTIMES ALPHA (SIN BETA T]) ) (PUTPROPS RANDOMVARS COPYRIGHT ("Xerox Corporation" 1986)) (DECLARE: DONTCOPY (FILEMAP (NIL (304 1499 (GAUSS-RV 314 . 1497))))) STOP