Xref: utzoo sci.math:5666 comp.sources.wanted:6341 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!ncifcrf!toms From: toms@ncifcrf.gov (Tom Schneider) Newsgroups: sci.math,comp.sources.wanted Subject: Re: random numbers Keywords: normal distribution, Gaussian Message-ID: <734@fcs280s.ncifcrf.gov> Date: 13 Feb 89 20:41:26 GMT References: <10471@ut-emx.UUCP> Reply-To: toms@ncifcrf.gov (Tom Schneider) Distribution: na Organization: NCI Supercomputer Center, Frederick, MD Lines: 27 In article <10471@ut-emx.UUCP> ken@ut-emx.UUCP (kenneth Moore) writes: >I am looking for a program to generate -Normal distributed > random numbers (for any mean and standard deviation).I would > be very thankful if any one can suggest a good source code > or send me one. > e-mail: (ken@emx.utexas.edu) The simplest way to generate such numbers is to add together several flat distribution numbers. This is very costly, and there is a better way. A friend showed me how to do this last week, so I put the code together today. It works fine. The program is in Pascal, and should work on any machine with a good compiler. Send me a note if you want a copy. It's not hard to do. If U is a member of the set [0..1] and Un and Un+1 are two members, then define theta = Un 2 pi r = sqrt(-2 ln(Un+1)) then when these polar coordinates are converted to Cartesian coordinates, one gets two independent Normally distributed numbers with mean 0 and standard deviation 1. To get other standard deviations multiply by a constant, and to get other means, add a constant. I don't know a reference, but I'm sure there are many. Tom Schneider National Cancer Institute Laboratory of Mathematical Biology Frederick, Maryland toms@ncifcrf.gov