How I generate a random number between 300 and 450?
Show older comments
Hi
I would like to generate a number between 300 and 450.
I also would like which is the possible ways to generate numbers on Matlab? Is there a Poisson generator for random numbers?
And what does the initial seed mean?
Thank you for your help.
1 Comment
Jan
on 19 Oct 2017
Do you mean integer or floating point numbers?
Accepted Answer
More Answers (2)
randi([300 450])
and everything you need is summarized here: https://www.mathworks.com/help/matlab/random-number-generation.html
5 Comments
zeezo
on 19 Oct 2017
Guillaume
on 19 Oct 2017
I'm sure you're able to read the documentation that KL linked to that clearly says that the distribution is uniform.
I'm also sure that you can put "matlab poisson random" into your favorite search engine which as its first result would get you to poissrnd (stats toolbox required)
zeezo
on 19 Oct 2017
Jan
on 19 Oct 2017
@Guillaume: I appreciate the "your favorite search engine". You take care for not advertising a commercial service, which we do not pay by money, but by our personal data. Thanks!
@zeezo: All details are explained exhaustively in the documentation. To use Matlab reliably, you have to read there at first.
zeezo
on 19 Oct 2017
I would like to generate a number between 300 and 450
I tried to use poissrnd but I couldn't generate a number between the two values.
A poisson distribution is defined over the range [0, Inf] and has only one parameter lambda (mean and variance). You cannot have a set of numbers that follow a poisson distribution and at the same time is restricted to a smaller range than [0 Inf].
You could generate random numbers that follow a poisson distribution with mean (300+450)/2, but you are guaranteed that with enough samples some of these will be out of the interval. Otherwise it is not a poisson distribution anymore.
1 Comment
Image Analyst
on 19 Oct 2017
Exactly correct. But if you, say, generated a million Poisson numbers between 0 and (say) 5000, and then threw them all away except those that landed between 300 and 450, it's not really Poisson anymore, is it? Indeed, it might even look rather uniform.
Categories
Find more on Univariate Discrete Distributions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!