# Generate random number biased to an input value

I've got enemies with a difficulty rating from 0 to 1. I want to generate a random reward that tends to increase as the difficulty rating rises, but still be possible to have a value anywhere in the range. Essentially, the average should increase with the difficulty, but maintain the full randomness range.

One attempt was to simply multiply a uniform random number by the difficulty, but this puts a cap on the output. What is the best approach to accomplish this?

• Possible duplicate of Continuous weighted random distribution, biased toward one end – Philipp Mar 21 '18 at 16:25
• @Philipp It's definitely similar. The reason I didn't flag it as a duplicate was because of the specific request here to have a tunable parameter to adjust the amount of bias, which isn't explicit in the earlier question (even though some of the answers do include such a parameter anyway) – DMGregory Mar 21 '18 at 16:51

rarity = 1 - Pow(random(), 1 + difficultyRating * maxBias)

Here maxBias is a positive value that lets you control how skewed you want your probabilities to get.