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.