Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Random sampling a variable record-length file.

by toma (Vicar)
on Dec 27, 2009 at 04:31 UTC ( #814478=note: print w/ replies, xml ) Need Help??


in reply to Random sampling a variable record-length file.

If you need statistically valid random numbers, don't use perl's rand(), it is not good for this purpose. It has patterns in it that will invalidate your results. I ran into this when I did a Monte Carlo simulation, and I was amazed at how bad the problem really is.

I tried several other algorithms for generating random numbers. Randomness turns out to be harder than it looks.

Any one who considers arithmetical methods of producing random digits is, of course, in a state of sin. óJohn von Neumann

See www.random.org for true random numbers.

It should work perfectly the first time! - toma


Comment on Re: Random sampling a variable record-length file.
Re^2: Random sampling a variable record-length file.
by BrowserUk (Pope) on Dec 27, 2009 at 09:17 UTC

    Indeed. Especially bad is the default rand on win32 with just 15-bits and a very poor LCG. I use Math::Random::MT.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-10-01 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (9 votes), past polls