Well, there are several ways of generating random numbers corresponding to a distribution from uniform[0,1] distributions ( thats what you essentially get when you use rand().)
Another way, if you have a nice function, is to use the inverse of the cumulative distribution function. Since the cumulative distribution function maps from [range of values in the distribution] to [0,1], and thus the inverse maps from [0,1] to [range of values], and the uniform is also from [0,1], you can get generate a random U(0,1) number, and plug it into the inverse of the CDF.
For more information about generating random numbers, check up a book on simulation. The textbook by Law and Kelton has a pretty comprehensive section on how to generate random numbers.
|