Open In App

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

Last Updated : 28 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will be looking at a guide to the dpois, ppois, qpois, and rpois methods of the Poisson distribution in the R programming language.

 dpois function

This function finds the probability that a certain number of successes occur based on an average rate of success, In other words, we can say as this function returns the value of the Poisson probability density function

Syntax: dpois(x, lambda)

Parameters:

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

Example:

In this example, we are finding the probability using the dpois function to get exactly 12 sales if the person makes 30 sales each hour in the R.

R




dpois(x=12, lambda=30)


Output:

[1] 0.0001038206

ppois function

This function finds the probability that a certain number of successes or less occur based on an average rate of success, In other words, we can say as this function returns the value of the inverse Poisson cumulative density function.

Syntax: ppois(q, lambda)

Parameters:

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

Example:

In this example, we are finding the probability using the ppois function to get sales or less if the person makes 30 sales each hour in the R.

R




ppois(q=12, lambda=30)


Output:

[1] 0.0001676976

qpois function

This function finds the number of successes that corresponds to a certain percentile based on an average rate of success, In other words, we can say as this function returns the value of the inverse Poisson cumulative density function

Syntax: qpois(p, lambda)

Parameters:

  • p: percentile
  • lambda: average rate of success

Example:

In this example, we are finding the probability to get the sales needed to make to be at the 80th percentile for sales in an hour,if the person makes 30 sales per hours in the R.

R




qpois(p=.80, lambda=30)


Output:

[1] 35

rpois function

This function generates a list of random variables that follow a Poisson distribution with a certain average rate of success, In other words, we can say as this function generates a vector of Poisson distributed random variables.

Syntax: rpois(n, lambda)

Parameters:

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

Example:

In this example, we are generating a list of 20 random variables that follow a Poisson distribution with a rate of success equal to 6.

R




rpois(n=15, lambda=6)


Output:

 [1] 5 9 4 7 7 9 6 8 4 3 9 3 2 2 9


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads