Generating Poisson random variates
Poisson distribution is best to use when expressing the probability of events occurring with a fixed time interval. These events are assumed to happen with a known mean rate, λ, and the event of the time is independent of the last event. Poisson distribution can be applied to examples such as incoming calls to customer service. In this recipe, we will demonstrate how to generate samples from Poisson distribution.
Getting ready
In this recipe, you need to prepare your environment with R installed.
How to do it…
Please perform the following steps to generate sample data from Poisson distribution:
Similar to normal distribution, we can use
rpois
to generate samples from Poisson distribution:> set.seed(123) > poisson <- rpois(1000, lambda=3)
You can then plot sample data from a Poisson distribution into a histogram:
> hist(poisson, main="A histogram of a Poisson distribution")
You can then obtain the height...