Generate Poisson Distributed Data in R

Your goal

You need to randomly generate Poisson distributed data in R.

Step-by-step tutorial

We will use the rpois function from the stats package to do this.

The exponential distribution has a single rate parameter, $$\lambda > 0$$. We'll generate 80 values using a rate of 10.

> data <- rpois(n=80, lambda=10)
> data
[1]  7  8 10  5 15 12 12  6 15 10 12 10 10 15 14 12 11  8 11  8  7  8  9 11 12
[26]  8  8  8 15  9 10 12 10  7 11 11  6 14  9 12 14 11  8  9 12 12  7 10  6  6
[51]  8  8  6  8 12  9 10 11  7  2  8 14 12  9 10 10  8  8  7  9  6  6 12 12  7
[76]  3 11  5  6  6

We can use hist to generate a histogram for the distribution:

> hist(data)
Histogram of Poisson distributed data