# A Guide to dpois, ppois, qpois, and rpois in R

This tutorial explains how to work with the Poisson distribution in R using the following functions

• dpois: returns the value of the Poisson probability density function.
• ppois: returns the value of the Poisson cumulative density function.
• qpois: returns the value of the inverse Poisson cumulative density function.
• rpois: generates a vector of Poisson distributed random variables.

Here are some examples of cases where you might use each of these functions.

## dpois

The dpois function finds the probability that a certain number of successes occur based on an average rate of success, using the following syntax:

dpois(x, lambda)

where:

• x: number of successes
• lambda: average rate of success

Here’s an example of when you might use this function in practice:

It is known that a certain website makes 10 sales per hour. In a given hour, what is the probability that the site makes exactly 8 sales?

```dpois(x=8, lambda=10)

#0.112599
```

The probability that the site makes exactly 8 sales is 0.112599.

## ppois

The ppois function finds the probability that a certain number of successes or less occur based on an average rate of success, using the following syntax:

ppois(q, lambda)

where:

• q: number of successes
• lambda: average rate of success

Here’s are a couple examples of when you might use this function in practice:

It is known that a certain website makes 10 sales per hour. In a given hour, what is the probability that the site makes 8 sales or less?

```ppois(q=8, lambda=10)

#0.3328197```

The probability that the site makes 8 sales or less in a given hour is 0.3328197.

It is known that a certain website makes 10 sales per hour. In a given hour, what is the probability that the site makes more than 8 sales?

```1 - ppois(q=8, lambda=10)

#0.6671803```

The probability that the site makes more than 8 sales in a given hour is 0.6671803.

## qpois

The qpois function finds the number of successes that corresponds to a certain percentile based on an average rate of success, using the following syntax:

qpois(p, lambda)

where:

• p: percentile
• lambda: average rate of success

Here’s an example of when you might use this function in practice:

It is known that a certain website makes 10 sales per hour. How many sales would the site need to make to be at the 90th percentile for sales in an hour?

```qpois(p=.90, lambda=10)

#14
```

A site would need to make 14 sales to be at the 90th percentile for number of sales in an hour.

## rpois

The rpois function generates a list of random variables that follow a Poisson distribution with a certain average rate of success, using the following syntax:

rpois(n, lambda)

where:

• n: number of random variables to generate
• lambda: average rate of success

Here’s an example of when you might use this function in practice:

Generate a list of 15 random variables that follow a Poisson distribution with a rate of success equal to 10.

```rpois(n=15, lambda=10)

#  13 8 8 20 8 10 8 10 13 10 12 8 10 10 6
```

Since these numbers are generated randomly, the rpois() function will produce different numbers each time. If you want to create a reproducible example, be sure to use the set.seed() command.