develooper Front page | perl.perl5.porters | Postings from March 2001

Re: [ID 20010305.005] "use integer" doesn't make rand() return integers

Thread Previous | Thread Next
From:
rspier
Date:
March 5, 2001 13:15
Subject:
Re: [ID 20010305.005] "use integer" doesn't make rand() return integers
Message ID:
15012.494.333302.850916@rls.cx
JP> I agree that the patch should not go in; my point was I'm not even
JP> sure that int(rand(10)) will not bias the random sequence returned
JP> by rand().  When dealing with random numbers, I know enough to
JP> know only that I don't know enough!  ;~)

I don't know enough either, but I'm pretty sure that "bias" is the
wrong word.  It will "quantize" the results.  But they should still be 
evenly[1] distributed between 0 and 9.  All that int (or floor) does is
chop off the non integer parts... It's not going to shift the nubers
up or down.  They will still be between 0 and 9.99999999999...

-R

[1] or as random as they were before we started mucking, however
random or un-random that might be.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About