delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/23/08:44:00

From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: randN
Date: Tue, 23 Nov 1999 09:16:55 +0200
Organization: NetVision Israel
Lines: 15
Message-ID: <Pine.SUN.3.91.991123091617.13225A-100000@is>
References: <383904BA DOT AE45DCDE AT mpx DOT com DOT au> <81bigt$1i5 AT acp3bf DOT knirsch DOT de>
NNTP-Posting-Host: is.elta.co.il
Mime-Version: 1.0
X-Trace: news.netvision.net.il 943341325 4483 199.203.121.2 (23 Nov 1999 07:15:25 GMT)
X-Complaints-To: abuse AT netvision DOT net DOT il
NNTP-Posting-Date: 23 Nov 1999 07:15:25 GMT
X-Sender: eliz AT is
In-Reply-To: <81bigt$1i5@acp3bf.knirsch.de>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 22 Nov 1999, Hans-Bernhard Broeker wrote:

> The typical method works by transforming the distribution.

A much simpler way is to generate 6 uniform random number (by calling
e.g. rand() 6 times), then return their average, suitably scaled to
give the normal Gaussian deviate (if I'm not mistaken, subtract 3 from
the average and divide the result by the square root of 2).

While seemingly stupid, this method is actually good enough to be
included as part of respectable numerical libraries such as IMSL.  The
theory behind it is the well-known theorem which states that the sum
of a large number of independent random numbers approaches the normal
distribution.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019