<< distfun_poisspdf Poisson distfun_poissstat >>

Distfun >> Distfun > Poisson > distfun_poissrnd

distfun_poissrnd

Poisson random numbers

Calling Sequence

R = distfun_poissrnd(lambda)
R = distfun_poissrnd(lambda,[m,n])
R = distfun_poissrnd(lambda,m,n)

Parameters

lambda :

a matrix of doubles, the average rate of occurrence. lambda>0.

m :

a 1-by-1 matrix of floating point integers, the number of rows of R

n :

a 1-by-1 matrix of floating point integers, the number of columns of R

R:

a matrix of doubles, the random numbers in the set {0,1,2,3,...}.

Description

Generates random variables from the Poisson distribution function.

Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.

Examples

// set the initial seed for tests
distfun_seedset(1);
// Test with expanded lambda
computed = distfun_poissrnd(1:6)
expected = [1 7 4 7 0 3];

// Check expansion of lambda in R = distfun_poissrnd(lambda)
distfun_seedset(1);
computed = distfun_poissrnd([12 14 20])
expected = [11 24 20];
// Check R = distfun_poissrnd(lambda,v)
computed = distfun_poissrnd(2,[4 5])

// Check mean and variance
N = 50000;
lambda = 13;
computed = distfun_poissrnd(lambda,[1 N]);
c = mean(computed(1:N))
d = st_deviation(computed(1:N) )
[M,V] = distfun_poissstat (lambda)

// Check actual distribution
lambda=12;
N=10000;
R=distfun_poissrnd(lambda,1,N);
h=scf();
distfun_inthisto(R);
h.children.children(1).children.background=-2;
x=0:2*lambda;
y=distfun_poisspdf(x,lambda);
plot(x,y,"ro-");
xtitle("Poisson Random Numbers","X","Frequency")
legend(["Empirical","Density"]);

Bibliography

http://en.wikipedia.org/wiki/Poisson_distribution

Authors


Report an issue
<< distfun_poisspdf Poisson distfun_poissstat >>