[Python-ideas] Shuffled
Sven R. Kunze
srkunze at mail.de
Tue Sep 6 15:20:55 EDT 2016
On 06.09.2016 20:46, Bernardo Sulzbach wrote:
> On 09/06/2016 03:37 PM, Sven R. Kunze wrote:
>>
>> Besides being a silly argument, it's an interesting solution.
>>
>> Does it really work? I remember Microsoft utilizing a similar approach
>> for their browser selection tool which led to a skewed probability
>> distribution. Maybe, I wrong here though.
>>
>
> Yes. The key is evaluated only once, so each element gets a
> pseudo-random number. Sorting this list leads to a shuffle.
Ah yes, that might make it work.
> However, a super-linear shuffle, whilst Fisher-Yates is a linear
> solution and also requires less additional memory.
>
> Lastly, although it is obvious, from a software engineering
> standpoint, this is a mere weird hack.
Sure, but it works. ;) Though I agree that's not really intuitive if you
are looking for "just shuffle that list, please".
Cheers,
Sven
PS: here's the statistical analysis of the browser ballot issue with
some explanations on the different algorithms on shuffling:
http://www.robweir.com/blog/2010/02/microsoft-random-browser-ballot.html
More information about the Python-ideas
mailing list