VOOZH about

URL: https://www.geeksforgeeks.org/r-language/poisson-functions-in-r-programming/

⇱ Poisson Functions in R Programming - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Poisson Functions in R Programming

Last Updated : 25 Jul, 2025

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:

 Parameters:

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

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 

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)

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

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

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.

Comment
Article Tags:

Explore