I want to generate a number that is close to zero with a certain general range. For example, let's say I want the number to fall under 10 90% of the time, but there's a small chance that it will be 15, 20, or even 30. The higher the number, the lower the chance of receiving it.
I've tried looking for something with the keywords "weighted probability" but can't find anything that leads in the right direction.
Update:
I ended up using the Box-Muller transform (see accepted answer). Here's the simple code I wrote:
const E = 2.71828183;
function getRandomCurvedValue(temp.median, temp.density) {
return this.getCurvedValue(random(0, 1), temp.median, temp.density);
}
function getCurvedValue(temp.value, temp.median, temp.density) {
return temp.median + (temp.density * log(E, (temp.value / (1 - temp.value))));
}