how to generate random numbers from a distribution which is the convolution of exponential distributions?
Mostra commenti meno recenti
Hello,
I would like to simulate two independent laser speckle intensities. Based on J. Goodman's book (Speckle Phenomena in Optics, p.39), the formula for the intensity distribution is the convolution of two exponential distributions:
p(i) = i/(I^2) exp(-i/I)
with I being the average intensity.
Is there already a function doing this? If not, how should I proceed to write it myself?
Thanks for the answer!
Cheers Guillaume
Risposta accettata
Più risposte (1)
Roger Stafford
il 20 Dic 2014
By integrating from 0 to infinity it can readily be determined that the cdf for your density p(x) = x/I^2*exp(-x/I) would be
u = F(x) = 1-(1+x/I)*exp(-x/I)
To generate a random variable with this cdf we need the inverse of this function. There may be one already lurking somewhere in the Statistics Toolbox, but I am not aware of it. However, the inverse can be computed using the 'lambertw' function. Its inverse is given by the matlab function 'lambertw' as:
x = (-lambertw(-1,(u-1)/exp(1))-1)*I;
where the initial -1 argument in the lambertw function indicates the appropriate branch for this many-branched function. Consequently you can generate your desired random variable with the single line:
x = (-real(lambertw(-1,(rand(n,1)-1)/exp(1)))-1)*I;
where n is the desired number of samples with this distribution. (Note: I have taken the real part of the lambertw output here because, at least for my copy of this function, it can produce very tiny imaginary parts due presumably to round-off error.)
Categorie
Scopri di più su Exponential Distribution in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!