Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Random sampling a variable record-length file.

by toma (Vicar)
on Dec 27, 2009 at 04:31 UTC ( [id://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.

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-20 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found