random exponential cdf numbers

How could I generate random results from an exponential cumulative distribution function?
Thanks, in advance!

 채택된 답변

bym
bym 2012년 6월 18일

0 개 추천

mu = 2 % mean of distribution
x = -mu*log(1-rand(1,10)); % ten numbers

댓글 수: 2

evan lan
evan lan 2012년 6월 21일
I thought it was the reverse type
mu = 2 % mean of distribution
p=1-exp(-rand(1,10)/mu);
Am I wrong?
bym
bym 2012년 6월 21일
Well, yes you are. Please see http://en.wikipedia.org/wiki/Inverse_transform_sampling

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2012년 6월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by