Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!iguana.cis.ohio-state.edu!adkins From: adkins@iguana.cis.ohio-state.edu (Brian Adkins) Newsgroups: comp.lang.c Subject: Re: Normal distribution random number generator -- WANTED Keywords: random number generator Message-ID: <86482@tut.cis.ohio-state.edu> Date: 2 Dec 90 19:13:19 GMT References: <1015@qusung.queensu.CA> Sender: news@tut.cis.ohio-state.edu Reply-To: Brian Adkins Organization: Ohio State University Computer and Information Science Lines: 20 >I am looking for C source code to generate normal distribution >random numbers. I want to be able to generate random numbers >in the range of 0 - N (N could be equal to 9999, 99999 or 999999) that >have normal distribution with mean, say, u and standard deviation s. I'm not sure if this is exactly what you want, but the Box-Muller method takes a pair of independent uniform variables ("regular random numbers") and creates a pair of standard normal variables: z1 = sqrt(-ln(u2)) * cos(2*PI*u1) z2 = sqrt(-ln(u2)) * sin(2*PI*u1) where the angle is expressed in radians. You probably can convert from standard normal variables to the specific case, but for completeness: x1 = u + s * z1, x2 = u + s * z2 where u is mean, s is std. dev. this method is almost universally preferred over solving for r = F(z) most of this info is from "Probability & Statistics for Engineers" Miller... Brought to you by Super Global Mega Corp .com