Matlab poisson random numbers

3 次查看(过去 30 天)
athpapa -
athpapa - 2011-3-11
Hello,
I use in my code the Matlab function 'poissrnd' to produce random numbers, for example: A=poissrnd(100,1,20) to produce 20 random numbers!But some times the poissrnd function returns 2 or more same values e.g. 20,20. Is there any way the 'poissrnd' function to produce total different numbers each time I run it?
Thank you!

回答(2 个)

Walter Roberson
Walter Roberson 2011-3-11
That wouldn't be a poisson distribution anymore. The bulk of the probability is concentrated near the mean.

Matt Tearle
Matt Tearle 2011-3-11
Any discrete distribution has a nonzero probability of producing repeats. If you don't want repeats then you're not sampling from a distribution, you're just permuting a set of values. For that, you can use randperm.
So the real question is what are you trying to achieve and why? I suppose you might want a random permutation, or portion thereof, that's weighted so that certain values are more likely to appear at the beginning of the sequence. In which case, you'll have to program that manually with a while loop. The ismember function could be useful.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by