5 ms·
If I recall correctly, this will get you a standard deviation of 1. let result = 0; for (let i = 0; i < 6; i++) { result += Math.random() - Math.random
by jtolmar 5y ago
If I recall correctly, this will get you a standard deviation of 1.
let result = 0;
for (let i = 0; i < 6; i++) {
result += Math.random() - Math.random();
}
return result;
Obviously this costs 12x as much as Math.random() itself, but it sure is simple.
(It'll also never return anything more than 6 standard deviations away from the mean, but it's not like you actually want that in most applications.)