List Commands Library for 50g

10062017, 08:00 PM
Post: #217




RE: List Commands Library for 50g
(10062017 03:04 AM)ttw Wrote: 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. The Marsaglia polar method is more robust; if RAND returns either a 0 or a 1, it will merely be rejected during the testing phase, and a new pair of random numbers will be generated. The Marsaglia method is a longer program than the BoxMuller method, but runs a bit faster. John 

« Next Oldest  Next Newest »

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