Dear Dr. Robert,
There are three errors in the program as follows:
1) line no. 1: A=6.283185308
2) line no. 3: C=RND
3) line no. 6: C=A*C
I think there is no need of writing RND(1) in your program. If you want
random seed every time you can write RANDOMIZE TIMER at the beggining of
the program. I hope it will work. Good luck.
Dr. David D. Hanagal
Reader in Statistics
Dept. of Statistics
University of Pune
Pune-411007, India
E-mail: [log in to unmask]
Fax: 0091(20)5650087
On Tue, 17 Aug 1999 [log in to unmask] wrote:
> 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]
>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|