Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Answer: How do I get random numbers that follow standard distribution?

by Roy Johnson (Monsignor)
on Feb 17, 2005 at 16:04 UTC ( [id://431984]=note: print w/replies, xml ) Need Help??


in reply to Re: How do I get random numbers that follow standard distribution?
in thread How do I get random numbers that follow standard distribution?

This page claims that the while condition should be } while ($w>=1 or $w==0);

Caution: Contents may have been coded under pressure.
  • Comment on Re: Answer: How do I get random numbers that follow standard distribution?
  • Download Code

Replies are listed 'Best First'.
Re^2: Answer: How do I get random numbers that follow standard distribution?
by hv (Prior) on Feb 18, 2005 at 11:56 UTC

    $w == 0 will occur only when $u1 == $u2 == 1/2, which will happen rarely enough that I can't see it skewing the results noticeably - even if you only have 32-bit random numbers, you'll hit this case only 1.27 in 2^64 times.

    (That 1.27 is based on my rusty attempts to calculate how many times we loop until we get $w < 1. I think the probability of a success is arcsin(1)/2, which is about 0.78.)

    Hugo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://431984]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2024-04-24 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found