This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Random numbers from Poisson distribution


r = poissrnd(lambda)
r = poissrnd(lambda,sz1,...,szN)
r = poissrnd(lambda,[sz1,...,szN])



r = poissrnd(lambda) generates random numbers from the Poisson distribution specified by the rate parameter lambda.

lambda can be a scalar, vector, matrix, or multidimensional array.


r = poissrnd(lambda,sz1,...,szN)or r = poissrnd(lambda,[sz1,...,szN]) generates an sz1-by-⋯-by-szN array containing random numbers from the Poisson distribution with the scalar rate parameter lambda.


collapse all

Generate an array of random numbers from the Poisson distributions. Specify the average rate for each distribution.

lambda = 10:2:20
lambda = 1×6

    10    12    14    16    18    20

Generate random numbers from the Poisson distributions.

r = poissrnd(lambda)
r = 1×6

    14    13    14     9    14    31

Generate an array of random numbers from one Poisson distribution. Here, the distribution parameter lambda is a scalar.

Use the poissrnd function to generate random numbers from the Poisson distribution with the avarage rate 20. The function returns one number.

r_scalar = poissrnd(20)
r_scalar = 9

Generate a 2-by-3 array of random numbers from the same distribution by specifying the required array dimensions.

r_array = poissrnd(20,2,3)
r_array = 2×3

    13    14    18
    26    16    21

Alternatively, specify the required array dimensions as a vector.

r_array = poissrnd(20,[2 3])
r_array = 2×3

    22    27    22
    25    19    21

Input Arguments

collapse all

Rate parameters, specified as a positive value or array of positive values. The rate parameter indicates the average number of events in a given time interval.

Example: 2

Data Types: single | double

Size of each dimension, specified as integers or a row vector of integers. For example, specifying 5,3,2 or [5,3,2] generates a 5-by-3-by-2 array of random numbers from the Poisson probability distribution.

If lambda is an array, then the specified dimensions sz1,...,szN must match the dimensions of lambda.

  • If you specify a single value sz1, then r is a square matrix of size sz1.

  • If the size of any dimension is 0 or negative, then r is an empty array.

  • Beyond the second dimension, poissrnd ignores trailing dimensions with a size of 1. For example, poissrnd(3,1,1,1) produces a 3-by-1 vector of random numbers.

Example: 5,3,2 or [5,3,2]

Data Types: single | double

Output Arguments

collapse all

Random numbers from the Poisson distribution, returned as a scalar value or an array of scalar values.

Data Types: single | double

Alternative Functionality

  • poissrnd is a function specific to Poisson distribution. Statistics and Machine Learning Toolbox™ also offers the generic function random, which supports various probability distributions. To use random, specify the probability distribution name and its parameters. Alternatively, create a PoissonDistribution probability distribution object and pass the object as an input argument. Note that the distribution-specific function poissrnd is faster than the generic function random.

  • To generate random numbers interactively, use randtool, a random number generation user interface.

Extended Capabilities

Introduced before R2006a