Non-uniform distributed random numbers

Creating non-uniform distrubed random numbers is not straightforward. Usally programming languages like C provide functions like rand() which returns an integer random number between 0 and RAND_MAX or drand48() with returns a double random number between 0 and 1. The numbers returned by these functions are uniform distributed meaning that if you run them very often you get each number by the same amount.
If you want random numbers in other ranges, these can be rescaled easily. For example, if you need integer random numbers between 1 and 10 you simply could get a random number x from rand() and apply the function \(f(x) = 1 + 9 \cdot x\) to it.

But what if you want to distribute them in a non-uniform way? Continue reading