in reply to Re: Re: Re: random elements from array - new twist
in thread random elements from array - new twist
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 sub shuffl selects 4 random numbers each with a possible value of 1, 2, 3 or 4, or a total of 44 (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 must be more likely than others.
Update: Oops. BrowserUK's shuffle is indeed a Fisher-Yates shuffle. $a = $_ + rand @{$r} - $_ is parsed as $a = $_ + (rand @{$r} - $_). I assumed it would be parsed as $a = $_ + (rand @{$r}) - $_
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Re: Re: random elements from array - new twist
by BrowserUk (Patriarch) on Nov 05, 2002 at 20:06 UTC |
In Section
Seekers of Perl Wisdom