List Commands Library for 50g

10062017, 03:04 AM
Post: #210




RE: List Commands Library for 50g
Normally, most uses of pseudorandomnumber generators do not generate 0.0 or 1.0. (This is for those approximating a real number on the unit interval.) Some common transformations of PRNGs fail on encountering 0 or 1. Example: generate an exponential distribution by taking Y=A*Log(U) where U is a real number on (0,1) and A is the proper constant to get the proper exponential (and Log is whatever log function is cheap to evaluate.) Similarly, the BoxMuller method of generating two independent normal random variates is: Y1=Sqrt(2*Ln(U1))*Sin(2*Pi*U2) and Y2=Sqrt(2*Ln(U1))*Cos(2*Pi*U2). Again there is a failure should U1 be zero.
I usually achieved this by generating a uniformly distributed integer J between 0 to 2^M, then transforming to an approximate by taking (2*J+1)/2^(M+1). 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)