Would personally suggest the following KISS technique to convert uniform distribution to slanted distribution:
Randomly (uniformly), draw a number x
between 0 and 1.
Now raise x
by some const predetermined p
value (likely) in the range between 1.1 to 7. The larger p
is, the more slanted (and less likely to hit extreme results) it'll be. Lets call x
by the power of p
our offset coefficient
. Now randomly pick a sign
(i.e plus or minus [negative, positive]). OK, the center
of your desired range is 10 == the max offset
from the center.
// Essentially
// center +/- offset = min/max
// 10 - 10 = 0
// 10 + 10 = 20
// So now, you simply do in pseudo code:
small_buffer = ~ 0.1 * range;
rand = randomize_float_between(0, 1);
coefficient = pow(rand, p);
sign = pick_one_of_these(-1, 1);
result = center + sign * coefficient * (offset + small_buffer);
result = max(0, min(result, 20)); // Keep it in range
This is the simplest way to get and tweak the effect you are looking for.