Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Generating Repeatable Pseudorandom Sequences

by dws (Chancellor)
on Sep 04, 2002 at 18:28 UTC ( #195154=note: print w/replies, xml ) Need Help??

in reply to Generating Repeatable Pseudorandom Sequences

For use in a shuffling algorithm, I need to be able to generate repeatable pseudo random sequences ... this code runs under mod_perl, it is possible that later code will require a random number that is not so deterministically chosen

Sounds like you needs to find or implement a random number generator that keeps its state within in instance of a package. That way you can have several generators active without them affecting each other (or interfering with rand() et al.).

A search on for "random" turns up a number of hits, including one for Math::Random, which looks like it might suit your purposes.

  • Comment on Re: Generating Repeatable Pseudorandom Sequences

Replies are listed 'Best First'.
Re: Re: Generating Repeatable Pseudorandom Sequences
by mp (Deacon) on Sep 04, 2002 at 19:58 UTC
    Thank you. After reading your reply, I realized that I really just needed a random number generator that could be seeded and that would not interfere with the builtin rand(). I looked at Math::Random, but ended up settling on Math::Random::MT. I ran some tests of the shuffle algorithm (to check the distribution of the permutations it would produce) with it in place in the Fisher-Yates shuffle algorithm and a set of seeds that were sequential, and it did a good enough job for this application.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2023-01-29 05:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found