Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: is rand random enough to simulate dice rolls?

by talexb (Chancellor)
on Jan 03, 2021 at 15:50 UTC ( [id://11126209]=note: print w/replies, xml ) Need Help??


in reply to Re: is rand random enough to simulate dice rolls?
in thread is rand random enough to simulate dice rolls?

Yup. You'll get an average of 3.5 after a large number of rolls (for some definition of 'large') .. but it's possible that you won't meet the (3.4,3.6) range based on a string of high or low runs in the random number generator, and your test will fail. At that point the user will go .. "Huh?" I'm not sure what their next step might be -- if they're familiar with module installation, they might try a make test, and see that it passes the next time, and continue on to do the install. And some people might ditch the installation completely.

I'd recommend you change that to a non-critical test.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Replies are listed 'Best First'.
Re^3: is rand random enough to simulate dice rolls?
by LanX (Saint) on Jan 03, 2021 at 16:24 UTC
    > but it's possible that you won't meet the (3.4,3.6) range based on a string of high or low runs in the random number generator, and your test will fail.

    But that's exactly what the definition of a PRNG guarantees.

    There *exists* a large number, such that the range is met in the run.

    Problematic is only the suggested number 10000, but my gut feeling says it's already big enough.

    I'd say if the OP wants to be sure of that, then he should include it in his test-suite.

    And if it's not critical enough to make the installation fail, he can still use it to emit a warning to the user.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-19 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found