On Fri, Jan 30, 2004 at 02:57:32PM -0600, J. Riley Bryant wrote:
> % perl -le 'for (1..1e5) { $i = 0; $a[$i++][$_]++ for sort { rand 2 }
> 1..8}; print "@{$_}" for @a'
[...]
> % perl -le '@_=(1..8); for (1..1e5) {$i=0; $a[$i++][$_]++ for
> @_=sort{rand [EMAIL PROTECTED] print "@{$_}" for @a'
[...]
> I don't really understand why @_=sort{rand [EMAIL PROTECTED] would seem
> to be more randomly distributed. 

The first version is somewhat analogous to taking a sorted deck of
cards, shuffling it once, noting the distribution of the cards,
sorting it back and shuffling it again, etc. The second one is like 
shuffling the cards, noting the distribution, shuffling again, etc. It
should be obvious which method will produce the better (umm...)
distribution of distributions.

-- 
Juho Snellman

Reply via email to