Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: the -other- shuffling question

by mstone (Deacon)
on Jun 13, 2005 at 04:39 UTC ( [id://466055]=note: print w/replies, xml ) Need Help??


in reply to Re: the -other- shuffling question
in thread the -other- shuffling question

As I understand it, shuffling doesn't decrease any desirable qualities. It only leaves them unchanged or increases them. It's vaguely like a sorting algorithm that preserves existing order.. sorting on B then sorting on A gives you a sequence sorted with A as the major key and B as the minor key. In this case, shuffling took a sequence that had no consecutive doubles and introduced a few.

If there are weaknesses, I'd like to know about those, too. I've found that some values for array size perform very badly (@T=7 leads to a period of 424, despite being relatively prime to $M), and adding a second shuffle doesn't seem to do much of anything. And clocking the generator:

$M = 8; $A = 5; $X = 0; $C = 0; sub lcrng { $X = (($X * $A) + 1) % $M; $C++; if ($C = $M-1) { $C = 0; $X = lcrng(); } return ($X); }

frankly sucks.

This all follows Knuth's admonition that RNGs are delicate creatures, and tend to be sensitive to 'minor' adjustments. I'd like to learn the theory behind these things so I know what's safe to touch.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-25 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found