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

Re: Random numbers generator

by davorg (Chancellor)
on Feb 07, 2001 at 19:33 UTC ( #56972=note: print w/ replies, xml ) Need Help??


in reply to Random numbers generator

Well, 'completely random' might be a bit of a problem, but if you'll settle for 'pseudo random' then this will do the trick:

my $random = int rand 10;
--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me


Comment on Re: Random numbers generator
Download Code
Re: Re: Random numbers generator
by mirod (Canon) on Feb 07, 2001 at 19:41 UTC

    It is just going to be a lot more difficult to ensure that if you run it on different machines it returns different results ;--)

    Maybe putting the result in an LWP accessible place, retrieving them and doing:

    my $random = int rand 10 while (($random != $previous_result1) && ($ra +ndom != $previous_result2)); print LWP_ACCESSIBLE $random;

    Or maybe the problem was not exactly properly stated...

(redmist) Re: Re: Random numbers generator
by redmist (Deacon) on Feb 07, 2001 at 23:06 UTC

    davorg is right. Computers (as they now exist) can never produce a truly random number. This is because, as Bruce Schneier puts it, "Computers are deterministic beasts: stuff goes in on one end, completely predictable operations occur inside, and different stuff comes out the other end." This enables back-computation.

    Computers need humans to be truly random. They do this by having humans entropize their entropy pool with mouse movements, thus enabling the creation of Truly Random numbers.

    redmist
    Silicon Cowboy

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-09-20 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (158 votes), past polls