audiolabs / webMUSHRA

a MUSHRA compliant web audio API based experiment software

Home Page:https://audiolabs.github.io/webMUSHRA/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change the algorithm used for "randomized experiments"

krlln opened this issue · comments

Hi,
The algorithm currently used for randomly ordering the experiment pages involves providing function() { return 0.5 - Math.random(); } to array.sort.
This method is biased: it is more probable for the first page in the YAML config file to be presented in the first pages. (see https://stackoverflow.com/a/18650169)
If possible, I'd recommend using the Fisher-Yates (aka Knuth) Shuffle as recommended here: https://stackoverflow.com/a/2450976.
Regards,
Krlln

webMUSHRA/startup.js

Lines 73 to 75 in c929877

_pages[i].sort(function() {
return 0.5 - Math.random();
});

Thanka for spotting this. Would you be able to provide a PR?

Yes I would. I'll write it tomorrow.