Effacer les filtres
Effacer les filtres

Matlab poisson random numbers

2 vues (au cours des 30 derniers jours)
athpapa -
athpapa - le 11 Mar 2011
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!

Réponses (2)

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

Matt Tearle
Matt Tearle le 11 Mar 2011
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.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by