MATLAB: How I generate a random number between 300 and 450

poissonrandrandom number generator

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.

Best Answer

You can create a "truncated" Poisson distribution that is based on the regular Poisson distribution, but with its range truncated to a given interval and its probability density function (PDF) adjusted so that the distribution remains a proper one (i.e., its integral over the truncation range equals 1).
For example, to generate numbers in the range [300, 450] from a truncated Poisson distribution, you could use
% Regular Poisson distribution
lambda = (300+450)/2; % To put the mean in the middle of the range
d = makedist('poisson', 'lambda', lambda)
% Truncated Poisson distribution
td = d.truncate(300, 450)
td.random(10,1) % Generate 10 random numbers in the range [300 450]
Related Question