In Matlab using the rand
routine, how should I write the code to generate 500 samples from an exponential distribution, whose pdf is:
(1/mu)*exp(-x/mu); x>=0
Assuming you really have to do it using the rand
function: exploit the property that the minus logarithm of a normalized uniform RV is a normalized exponential RV:
samples = -mu*log(rand(1,500));