Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

poissrnd

Poisson random numbers

Syntax

R = poissrnd(lambda)
R = poissrnd(lambda,m,n,...)
R = poissrnd(lambda,[m,n,...])

Description

R = poissrnd(lambda) generates random numbers from the Poisson distribution with mean parameter lambda. lambda can be a vector, a matrix, or a multidimensional array. The size of R is the size of lambda.

R = poissrnd(lambda,m,n,...) or R = poissrnd(lambda,[m,n,...]) generates an m-by-n-by-... array. The lambda parameter can be a scalar or an array of the same size as R.

Examples

Generate a random sample of 10 pseudo-observations from a Poisson distribution with λ = 2.

lambda = 2;

random_sample1 = poissrnd(lambda,1,10)
random_sample1 =
   1   0   1   2   1   3   4   2   0   0

random_sample2 = poissrnd(lambda,[1 10])
random_sample2 =
   1   1   1   5   0   3   2   2   3   4

random_sample3 = poissrnd(lambda(ones(1,10)))
random_sample3 =
   3   2   1   1   0   0   4   0   2   0

Introduced before R2006a

Was this topic helpful?