rtpois | R Documentation |
This generates random numbers from a zero-truncated Poisson distribution,
i.e. from X | X > 0
when X ~ Poisson(lambda)
. The advantage here is that
we guarantee to return exactly n
numbers and without using a loop internally.
This solution was provided in a post by
Peter Dalgaard.
rtpois(n, lambda)
n |
( |
lambda |
( |
The random numbers.
x <- rpois(1e6, lambda = 5)
x <- x[x > 0]
hist(x)
y <- rtpois(1e6, lambda = 5)
hist(y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.