how to generate random numbers from a distribution which is the convolution of exponential distributions?
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Roger Stafford
2014년 12월 20일
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.)
카테고리
도움말 센터 및 File Exchange에서 Exponential Distribution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!