Path: utzoo!attcan!uunet!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!CGEUGE54.BITNET!BARTHO From: BARTHO@CGEUGE54.BITNET (PAUL BARTHOLDI) Newsgroups: comp.lang.forth Subject: mathematical routines (realy random numbers) Message-ID: <9003161408.AA25741@jade.berkeley.edu> Date: 16 Mar 90 09:34:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: PAUL BARTHOLDI Organization: The Internet Lines: 34 >Category 3, Topic 10 >Message 37 Wed Mar 14, 1990 >HARV at 03:27 MST > > Subject: Random Number Generators > I am currently working on Monter Carlo simulation program. The literatue > sources I have available stat that a linear and Gaussian random number > generators are required. I have a shuffling random number generator alreay >and think that it is a linear one. Any clarification of this matter would > be greatly appreciated. I am especially interested if there is some way I > can modify my existing random number generator to produce Gaussian random >numbers. Two solutions : I assume that all your numbers are between 0 and 1. Then 1. sum 12 uniform random numbers, and substract 6. You get a ~gaussian number, with mean=0.0 and variance=1.0 . If you need gaussian with mean m and variance v, then multiply previous gaussian by v and add m . For realy most applications, this is a good gaussian generator. Only limitation : you will never get number above ou below 6 sigma ! 2. take 2 uniform random numbers x1 and x2, then calculate : n1 = sqrt( -2*log(x1) ) * cos( 2 * pi * x2) n2 = sqrt( -2*log(x1) ) * sin( 2 * pi * x2) then n1 and n2 are two independant gaussian random numbers, with mean=0 variance=1. See above for other means or variances. Ref: any book on Monte Carlo Methods, for example : J. M. Hammersley and D. C. Handscomb Monte Carlo Methods Methuen's Monographs on Applied Probability and statistics John Wiley and Sons Inc, London - New York 1964