Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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 for true random numbers.

It should work perfectly the first time! - toma
  • Comment on Re: Random sampling a variable record-length file.

Replies are listed 'Best First'.
Re^2: Random sampling a variable record-length file.
by BrowserUk (Patriarch) 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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2023-12-09 18:50 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (38 votes). Check out past polls.