random number generator
    Geoff Clare 
    gwc at root.co.uk
       
    Tue Mar  1 23:25:41 AEST 1988
    
    
  
In article <225800004 at uxe.cso.uiuc.edu> mcdonald at uxe.cso.uiuc.edu writes:
>
>>Simplistic, but this works:
>>Generate about 12 random numbers (assuming 0.0 <= i <1.0)
>
>       ADD THEM TOGETHER
	SUBTRACT 6   !!!!
>
>>and divide by 12.  This is sufficiently close to gaussian distribution
>>for most purposes.  The more numbers you generate before you do the
>>division, the closer you will get to purely gaussian distribution.
NO NO NO NO NO!
Only *exactly* 12 random numbers used in this way will give an
approximate Gaussian.  Any other number will not give the right variance.
(The variance of a uniform distribution over [0,1] is 1/12).
-- 
Geoff Clare    UniSoft Limited, Saunderson House, Hayne Street, London EC1A 9HH
gwc at root.co.uk   ...!mcvax!ukc!root44!gwc   +44-1-606-7799  FAX: +44-1-726-2750
    
    
More information about the Comp.lang.c
mailing list