Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: generate random number without using any built in function in perl?

by Laurent_R (Parson)
on May 08, 2013 at 22:08 UTC ( #1032688=note: print w/ replies, xml ) Need Help??


in reply to Re: generate random number without using any built in function in perl?
in thread generate random number without using any built in function in perl?

Not to be obtuse, but why can't you use rand? This smacks of an XY Problem.

Yes, I fully agree.

To the OP: please tell us why you can't (or don't want to) use the Perl random number generator, which is, I think, of a high quality and has been well tested over many years, and would want to go for something else, which is likely to work much less properly unless you are willing to commit huge amount of time to test how well it performs.

I once made a very basic pseudo random number generator, because I did not have any library available to do that for me in the environment that I was using. It ended up working for the purpose that I had, because the requirement was really not demanding. But trying to do that, you figure out that this is a very difficult problem, and sometimes very clever ideas fail miserably. (I knew it was quite difficult before I started, but I did not realize how much more difficult than I thought it was.)

I would suggest that you take a look at Donald Knuth's "The Art of of Computer Programming", Volume 2, Seminumerical Algorithms, Chapter 3, Random Numbers. Once you've read through the 190 pages (in the edition that I own) devoted to random numbers, I think that you will agree that you probably don't want a "quick fix" solution to such a complicated problem. Using a well tested library is far safer in probably more than 99.99% of the cases.


Comment on Re^2: generate random number without using any built in function in perl?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (11)
As of 2014-10-20 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (74 votes), past polls