[Chicago-talk] Random first numbers

Alan Mead amead2 at alanmead.org
Mon May 17 16:29:51 PDT 2010


Dean Serenevy wrote:
> On 05/17/2010 05:25 PM, Alan Mead wrote:
>   
>> Assuming that shuffle() is not the culprit, I think it's just that when
>>     
>
> Bad assumption. That is not the Fisher-Yates shuffle. Try this (from perlfaq):
>
> sub shuffle {
>   my $n = @_;
>   while (--$n) {
>     my $j = int rand ($n+1);
>     @_[$n,$j] = @_[$j,$n];
>   }
> }
>
>   

Under light testing, this seems much better.  Thanks!

-Alan

-- 
Alan D. Mead, Ph.D.
Assistant Professor of Industrial and Organization Psychology
Scientific Advisor to the Center for Research and Service
Illinois Institute of Technology
3101 South Dearborn, 2nd floor
Chicago IL 60616
+312.567.5933 (Campus)
+815.588.3846 (Home Office)
+312.567.3493 (Fax)

http://www.iit.edu/~mead
http://www.center.iit.edu
http://www.alanmead.org

He who fights with monsters should be careful lest he
thereby become a monster.
-- Friedrich Nietzsche, "Beyond Good and Evil"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20100517/d96444b8/attachment.html>


More information about the Chicago-talk mailing list