Today a friend approached me to look at a short computer routine that prodces
normally distributed values. He called it the Box-Muller Method.
When I looked it over there appeard to be an error in the programming.
Briefly this is the program he showed me. It was written in BASIC. I am
interested in determining the correct routine and, if possible, the logic
behind it.
A=2.283185308
B=RND(1)
C=RAN(1)
B=-2*LOG(B)
B=SQR(B)
C=A*B
Z1=B*SIN(C)
Z2=B*COS(C)
The routine appears to generate two numbers on each run and when they are
collected 100, or so, they do appear to form a normal distribution.
If you look at the program the 3rd step calculates a value of C but then
three steps later, C is set equal to A time B. The original value of C in
step 3 never is used. I am interested in whether this is an error or simply
poor programming.
Any help with the method, the logic behind it and the correct computer
routine would be appreciated.
If you know of any other simple algorithms that can be used to produce
normally distributed values I would appreicate knowing about them.
Dr. Robert C. Knodt
4949 Samish Way, #31
Bellingham, WA 98226
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|