in reply to Fisher-Yates theory... does this prove that it is invalid?
in thread Fisher-Yates theory
The problem is, your shuffle routine is not an implementation of a Fisher-Yates shuffle.
This line
my $j = shift @$rand;
is no way equivalent to this line from the FAQ implementation
my $j = int rand ($i+1);
The latter picks a swap partner for the current value of $i, randomly between 0 and $i-1. I can't quite wrap my brain around what your code is doing here, but it isn't even vaguely equivalent.
Therefore you are not testing a Fisher-Yates shuffle, but some shuffle algorithm of your own invention, which you succeed in proving isn't as good as the Fisher-Yates.
You might find this post Re: When the Best Solution Isn't that does a statistical analysis of several shuffle routines, a Fisher-Yates amongst them, including frequency and standard deviation interesting.
|
|---|