T.R | Title | User | Personal Name | Date | Lines |
---|
938.1 | | BEING::POSTPISCHIL | Always mount a scratch monkey. | Fri Sep 30 1988 14:25 | 15 |
| Here's an algorithm to generate two numbers, n1 and n2, selected from a
Gaussian distribution with mean m and standard deviation s, given
numbers r1 and r2 which were selected from a uniform distribution in
[0,1).
t1 = sqrt(-2 ln(r1)) sin(2 pi r2)
t2 = sqrt(-2 ln(r1)) cos(2 pi r2)
n1 = s t1 + m
n2 = s t2 + m
From Kiyoshi Akima, PPC Journal, who got it from Donald E. Knuth.
-- edp
|
938.2 | Same algorithm, faster implementation. | PBSVAX::COOPER | Topher Cooper | Fri Sep 30 1988 16:12 | 22 |
| Here is essentially the same algorithm from Knuth (Vol 2), in a
form which avoids the calculation of the sin and cos.
Let U1, and U2 be two independent uniform [0, 1). Let
V1 = 2*U1 - 1; V2 = 2*U2 - 1;
(V1 & V2 are uniformly distributed between -1 and 1).
Let S = V1^2 + V2^2 and check to see if it is greater than 1, if
it is get two more U's and try again. According to Knuth this
will repeat on the average of about 1.27 times.
Now t1, and t2 are calculated as
t1 = V1*sqrt(-2 ln(S)/S); t2 = V2*sqrt(-2 ln(S)/S);
These are independently distributed according to the standard normal
distribution (mean = 0, sd = 1), and can be rescaled for a different
mean and sd as in .1.
Topher
|
938.3 | | CLT::GILBERT | Multiple inheritence happens | Mon Oct 03 1988 10:16 | 2 |
| Also, check the recent literature. I recall seeing a new improved
algorithm in the Journal of Mathematics sometime in the past 2 yrs.
|
938.4 | Faster algorithms | CTCADM::ROTH | Lick Bush in '88 | Mon Oct 03 1988 12:43 | 11 |
| See also the June 1986 issue of IEEE Micro for a much faster algorithm.
(But the quality of the ones above is excellent.)
Another useful reference is
Marsaglia and Tsang
"A fast, easily implemented method for sampling from decreasing
or symmetric unimodal density functions"
SIAM J. Scientific and Statistical Computing, June 1984
- Jim
|