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 exactlyk events\lambda (lambda): Average number of events in the given intervalk : Actual number of events that occurrede : Euler’s number (approximately 2.718), the base of the natural logarithmk! : Factorial ofk
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
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); ifFALSE, calculates P(X > q)
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
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
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.