generate n random number between two numbers follow exponential distribution
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Mos_bad
il 12 Feb 2019
Modificato: Star Strider
il 12 Feb 2019
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
0 Commenti
Risposta accettata
Star Strider
il 12 Feb 2019
Experiment to get the result you want.
2 Commenti
Star Strider
il 12 Feb 2019
Modificato: Star Strider
il 12 Feb 2019
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
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/203860/image.png)
Experiment to get the result you want.
Più risposte (1)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!