note
jsprat
<strike>Your algorithm is not a Fisher-Yates shuffle. <code>shuffl</code> chooses a random number between 1 and the number of elements (inclusive) each time.</strike> A Fisher-Yates shuffle chooses from a smaller set each iteration to avoid performing a biased shuffle.<p>
Using the dataset A, B, C and D there are 24 possible outcomes (4!), each one with an equal probability of 1/24. The algorithm used for <code>sub shuffl</code> selects 4 random numbers each with a possible value of 1, 2, 3 or 4, or a total of 4<sup>4</sup> (256) possible outcomes, each with a probability of 1/256 (some of the final permutations are duplicated). 256 is not evenly divisible by 24, so some of the outcomes <b>must</b> be more likely than others.<p><b>Update:</b> Oops. [BrowserUK]'s shuffle is indeed a Fisher-Yates shuffle. <code>$a = $_ + rand @{$r} - $_</code> is parsed as <code>$a = $_ + (rand @{$r} - $_)</code>. I assumed it would be parsed as <code>$a = $_ + (rand @{$r}) - $_</code>
210389
210544