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:

  1. Similar to normal distribution, we can use rpois to generate samples from Poisson distribution:
    > set.seed(123)
    > poisson ...

Get R for Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.