Open In App
Related Articles
• Write an Interview Experience
• Machine Learning with R

# Poisson Functions in R Programming

The Poisson distribution represents the probability of a provided number of cases happening in a set period of space or time if these cases happen with an identified constant mean rate (free of the period since the ultimate event). Poisson distribution has been named after Siméon Denis Poisson(French Mathematician).
Many probability distributions can be easily implemented in R language with the help of R’s inbuilt functions.
There are four Poisson functions available in R:

• dpois
• ppois
• qpois
• rpois

Consider a Random Variable X with Poisson distribution given as The mean of this distribution is given by The variance of such a distribution is So if there are ‘n’ which happened out of which the only k were successful when the probability of success is very less then the probability of success becomes #### dpois()

This function is used for illustration of Poisson density in an R plot. The function dpois() calculates the probability of a random variable that is available within a certain range.
Syntax: where,

K: number of successful events happened in an interval mean per interval
log: If TRUE then the function returns probability in form of log

Example:

## Python3

 dpois(2, 3)dpois(6, 6)

Output:

 0.2240418

 0.1606231

#### ppois()

This function is used for the illustration of cumulative probability function in an R plot. The function ppois() calculates the probability of a random variable that will be equal to or less than a number.
Syntax: where,

K: number of successful events happened in an interval mean per interval
lower.tail: If TRUE then left tail is considered otherwise if the FALSE right tail is considered
log: If TRUE then the function returns probability in form of log

Example:

## Python3

 ppois(2, 3) ppois(6, 6)

Output:

 0.4231901
 0.6063028

#### rpois()

The function rpois() is used for generating random numbers from a given Poisson’s distribution.
Syntax: where,

q: number of random numbers needed mean per interval

Example:

## Python3

 rpois(2, 3)rpois(6, 6)

Output:

 2 3
  6  7  6 10  9  4

#### qpois()

The function qpois() is used for generating quantile of a given Poisson’s distribution.
In probability, quantiles are marked points that divide the graph of a probability distribution into intervals (continuous ) which have equal probabilities.
Syntax: where,

K: number of successful events happened in an interval mean per interval
lower.tail: If TRUE then left tail is considered otherwise if the FALSE right tail is considered
log: If TRUE then the function returns probability in form of log

Example:

## Python3

 y <- c(.01, .05, .1, .2)qpois(y, 2)qpois(y, 6)

Output:

 0 0 0 1
 1 2 3 4