Assumption: You can generate X, a random number from a Uniform[0,1] Distribution. There are many ways to do that.
The objective is to turn X, which is uniformly distributed between 0 and 1, into Y, which is a random number from a probability distribution of your choosing. Examples of probability distributions are the Normal Distribution, Exponential Distribution, and Beta Distributions.
Key insight: All probability values are between 0 and 1. The cumulative distribution function (CDF) for a probability distribution gives the percent of the distribution that is below a value in the distribution. Take X, the number in Uniform[0,1], and transform it into Y, a value in your distribution of interest that has CDF X.
Example: Say you generate X=.766 and want a random number, Y, from the standard normal distribution (mean=0, standard deviation=1). Abbreviate the standard normal distribution as N[0,1]. Let F(x) be the CDF of N[0,1]. To generate Y~N[0,1], we need to find , where is the inverse of the CDF. We can look up in a normal distribution table or by using the function norm.inv(.766,0,1) in Excel. We find that the value of interest is Y=.7257.
For distributions whose CDF is invertible, we can find equations for Y, the random number from the distribution. Take the exponential distribution for example. The CDF of the exponential distribution with mean is . Solve for y. We find . Now, when we generate any X~U[0,1], we can use the equation for to find Y, which is a random number from the exponential distribution.
For distributions whose CDF is not continuous, you will want to find the smallest Y who has a CDF of at least X.