Normal distribution random number generator -- WANTED

Wilf Leblanc wilf at sce.carleton.ca
Sat Dec 1 15:46:33 AEST 1990


winarko at qucis.queensu.CA (Edi Winarko) writes:

>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.

Add M random uniform random numbers x (where x is between 0 and
N/M).  Using M = 12 to 30, will generate random variables which
are very close to normal, (not quite, but your specification
of limits ensures the results will not 'truly' be normal).
This works because of the central limit theorem (see any
probability text).  The variance and mean are easily computable
from M and N.

I hope this helps.  If you want source code, mail me.

>Thanks for any help,

>--Edi W
>winarko at qucis.queensu.ca

--
---
Wilf LeBlanc                                Systems and Computer Eng.
Internet: wilf at sce.carleton.ca              Carleton University
    UUCP: ...!uunet!mitel!sce!wilf          Ottawa, Ont, Canada



More information about the Comp.lang.c mailing list