Re:Busy Simulator: Feign importance with repeating app sounds
by CraigJPerry on Wednesday December 15, 2021 @07:43AM
(#29565190)
That’s a neat solution, my instinct would have been futzing with the universal distribution of Math.random() into a normal distribution (incurring even more cost than the Math.log() call in the process).
[ Parent
| on HN ]
Re:Busy Simulator: Feign importance with repeating app sounds
by jtolmar on Wednesday December 15, 2021 @01:34PM
(#29569841)
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.)