Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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;

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

Replies are listed 'Best First'.
(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.

    Silicon Cowboy
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...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://56972]
[Eily]: that's one long sheband

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2018-05-25 08:14 GMT
Find Nodes?
    Voting Booth?