Friday, 19 August 2011

Generating exponentially distributed random numbers

If you can generate uniformly distributed random numbers, you can generate exponentially distributed random numbers. Here's the MATLAB code:
expRandomNumbers = -1/lambda*log(1-rand(1,N));
where lambda is the rate parameter and N is the number of random samples you want.

No comments:

Post a Comment