Exponential Distribution for random number

Hi, How can i generate an exponential distributed random integer from the interval [1 16]. Thank you so much.

 Accepted Answer

I need a bit of clarification. Are the means on the interval [1 16], do you want the output to be on the interval 1 16, or a row vector of 16 exponentially distributed random variables? You have to specify a mean (or an array of means) in the second and third instances. (You can do any of these easily enough, but the output are no longer strictly exponentially distributed in the second instance.)

6 Comments

Hi, I want the output to be from the interval 1 to 16. At the moment i am using uniform random distribution for the same thing but now i want to change it to exponential distribution.
randi(16,1,1)
You have to specify a mean. After that, the rest is easy:
mu = 10; % Specify Mean
rnexp = exprnd(mu, 1, 100); % Generate Random Vector
fixlim = fix(rnexp(rnexp>=1 & rnexp<=16)); % Round & Limit Magnitude
I generated a vector of them here, which has the advantage of your being able to then use a randi call to randomly select one of them, by selecting the index:
exrnd = randi(length(fixlim)); % Selects One Element Of ‘fixlim’
This should do what you want.
Ok this is done but one thing i want to ask you for my basic understanding about distributions, that when we say non-uniform random distribution, does it refer to any distribution other than uniform or does it mean some specific distribution with the name non-uniform.
Your non-uniform random variate question turned out to be much more involved than I can answer here, and even Wikipedia avoids it. The short answer appears to be that it is any distribution that is not uniform, not a specific distribution named ‘non-uniform’.
I did an online search to be certain. A comprehensive discussion is at NON-UNIFORM RANDOM VARIATE GENERATION. (Other discussions I found online are as involved.) The same author has published a book on the subject.
Hi, Thank you for it. Take care & good nite.
My pleasure.
Thank you. You, too!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!