poisson
Builtin index · Statistics & ML
result = poisson(lambda, [rows], [cols], [seed=])
Input: lambda, rows, cols, seed · Output: result
What it is
Exact Poisson draws. lambda (a positive number) is the rate, which is also the mean and the variance of the result; rows and cols (numbers, optional) give the shape of the draw, one number for a vector and two for a matrix; seed= (number, optional) makes the draw repeatable. Slow, not wrong, for very large lambda.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = poisson(lambda, [rows], [cols], [seed=]) | lambda numberlambda (a positive number) is the rate, which is also the mean and the variance of the result.rows number, vector, or matrix, optionalrows and cols (numbers, optional) give the shape of the draw, one number for a vector and two for a matrix.cols number, vector, or matrix, optionalrows and cols (numbers, optional) give the shape of the draw, one number for a vector and two for a matrix.seed number, optionalseed= (number, optional) makes the draw repeatable. | result number, vector, or matrix | Returns a number, vector, or (rows, cols) matrix of non-negative integers. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
u = uniform(10, 20, 5) # 5 draws, continuous uniform on [10, 20)
g = normal(5, 2, 1000, seed=1) # 1000 draws, mean 5, std 2 — randn is mu=0/sigma=1
d = randi(1, 6, 10) # 10 dice rolls, inclusive both ends
k = poisson(4, 500) # 500 draws from Poisson(lambda=4)
t = exponential(2, 500) # 500 draws, rate=2 (mean = 1/rate = 0.5)
b = binomial(20, 0.3, 500) # 500 draws, 20 trials at p=0.3 each
from numerics-dsp
How it works
poisson(lambda, ...) — see Rng::poisson's doc comment for the exact-vs-large-lambda tradeoff.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.