generate n random number between two numbers follow exponential distribution

7 次查看(过去 30 天)
I need to generate n random number between a and b which follow the exponential distribution (In this perticular case a=0, b=75, random number =t=occurance time; I need exactly "n=60" random numbers of "t" which are less than 75). here is what I have done:
mu=475; % return period
lambda=1/mu; % occurance rate
u=rand(100,1); % uniform random numbers between 0 and 1
t=icdf('Exponential',u,mu); % exponential random numbers of time

采纳的回答

Star Strider
Star Strider 2019-2-12
I would use the Statistics and Machine Learning Toolbox exprnd (link) function.
Experiment to get the result you want.
  2 个评论
Mos_bad
Mos_bad 2019-2-12
Thanks for the response. If doing so, how I can generate ''n'' random numbers between "a" and "b" ?
Star Strider
Star Strider 2019-2-12
编辑:Star Strider 2019-2-12
My pleasure.
Try this:
mu = 475;
n = 1E+5;
R = exprnd(mu,1,n);
a = 10;
b = 20;
Rbounded = R((R>=a) & (R<=b));
n = 42;
R_return = Rbounded(randperm(numel(Rbounded),n));
That will give you ‘n’ values from the exponential distribution with .
Experiment to get the result you want.

请先登录,再进行评论。

更多回答(1 个)

Jeff Miller
Jeff Miller 2019-2-12
With Cupid the command is
somerands = TruncatedX(Exponential(lambda),a,b).Random(n,1);

Community Treasure Hunt

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

Start Hunting!

Translated by