Say, if I wanted to generate an unbiased random number between min
and max
, I'd do:
var rand = function(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
But what if I want to generate a random number between min
and max
but more biased towards a value N
between min
and max
to a degree D
? It's best to illustrate it with a probability curve: