DEV Community

Discussion on: Some Powerful Js One-liners

Collapse
 
mellen profile image
Matt Ellen • Edited

In case anyone is interested, I plotted the distributions for the Math.random() - 0.5 and the Fisher-Yates shuffles.

Chart of shuffle using Math.random() - 0.5. Shows clearly uneven distribution

Chart of Fisher-Yates shuffle algorithm. Shows a distribution much closer to even

That's 100000 shuffles of abcd for each algorithm.