V
VK
Assuming one needs to have a function returning false or true on each
call in pseudo-random order.and using JavaScript native Math.random()
method as the basis of the pseudo-randomness. Say the variants of such
function are:
getAnswer1() {
var n = Math.round(Math.random());
return n ? true : false;
}
getAnswer2() {
var n = Math.floor(Math.random()*2);
return (n==2) ? true : false;
}
Leaving obvious practical testing by platforms aside:
Is there are theoretical considerations that pseudo-randomness
(predictability) of either of above will be better or worse than the
other one? JavaScript Kit site claims that the second bits first:
http://www.javascriptkit.com/javatutors/randomnum.shtml
but they don't disclose the underlaying reasoning.
call in pseudo-random order.and using JavaScript native Math.random()
method as the basis of the pseudo-randomness. Say the variants of such
function are:
getAnswer1() {
var n = Math.round(Math.random());
return n ? true : false;
}
getAnswer2() {
var n = Math.floor(Math.random()*2);
return (n==2) ? true : false;
}
Leaving obvious practical testing by platforms aside:
Is there are theoretical considerations that pseudo-randomness
(predictability) of either of above will be better or worse than the
other one? JavaScript Kit site claims that the second bits first:
http://www.javascriptkit.com/javatutors/randomnum.shtml
but they don't disclose the underlaying reasoning.