![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^3: Random 1-1 mappingby blokhead (Monsignor) |
on May 28, 2006 at 21:26 UTC ( #552217=note: print w/replies, xml ) | Need Help?? |
A mapping of the form
is 1-to-1 (restricted to 0 <= x < m) as long as gcd(a,m)==1, since that's the only time you can find an inverse to a mod m, and invert the function. I would suggest splitting your "seed" value into the a & b coefficients in the following way:
But take this approach for what it's worth -- The only kinds of mapping you'll get by this process are simple linear (affine) mappings, which may not "look random enough": For more "unpredictable" orders, you could have more tools at your disposal if $max is always a prime. Then you take one of the linear sequences above and use it as a sequence of powers of a generator element for the field mod $max. blokhead
In Section
Seekers of Perl Wisdom
|
|