Open In App

Poisson Functions in R Programming

Last Updated : 25 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The Poisson distribution is a probability distribution used to model the number of times an event occurs in a fixed interval of time or space. It assumes that the events occur independently and at a constant average rate.

Formula:

P(X=k)= \frac{e^{-\lambda}\lambda^{k}}{k!}  

 Parameters:

  • P(X = k): Probability of observing exactly k events
  • \lambda (lambda): Average number of events in the given interval
  • k: Actual number of events that occurred
  • e: Euler’s number (approximately 2.718), the base of the natural logarithm
  • k!: Factorial of k

R programming language provides built-in support for Poisson distribution through four core functions.

1. Poisson Probability Mass Function

The dpois() function calculates the probability of observing exactly k events in a Poisson distribution.

Syntax: 

dpois(k, lambda, log = FALSE)

Parameters:

  • log: If TRUE then the function returns probability in form of log 
R
dpois(2, 3)
dpois(6, 6)

Output: 

[1] 0.2240418

[1] 0.1606231


2. Poisson Cumulative Distribution Function

The ppois() function calculates the cumulative probability of having k or fewer events.

Syntax:

ppois(q, lambda, lower.tail = TRUE, log = FALSE)

Parameters:

  • q: Number of events
  • lower.tail: If TRUE, calculates P(X ≤ q); if FALSE, calculates P(X > q)
R
ppois(2, 3)
ppois(6, 6)

Output:

[1] 0.4231901
[1] 0.6063028

3. Poisson Random Number Generation

The rpois() function generates random numbers following a Poisson distribution.

Syntax: 

rpois(n, lambda)

  • q: number of random numbers needed 
  • lambda: mean per interval
R
rpois(2, 3)
rpois(6, 6)

Output: 

[1] 2 3
[1] 6 7 6 10 9 4

4. Poisson Quantile Function

The qpois() function calculates the smallest value k such that the cumulative probability is at least p.

Syntax:

qpois(p, lambda, lower.tail = TRUE, log = FALSE)

Parameters:

  • lower.tail: If TRUE, computes lower tail; otherwise upper tail
R
y <- c(0.01, 0.05, 0.1, 0.2)
qpois(y, 2)
qpois(y, 6)

Output: 

[1] 0 0 0 1
[1] 1 2 3 4

These functions allow us to work with Poisson-distributed data in R programming language.


Explore