Poisson Distribution in R Programming

Poisson distribution is a type of distribution that deals with the probability distribution of the data values by taking the mean into consideration. Poisson distribution will estimate the probability value for a number of cases with the specific events happening at a constant mean rate. In short, it will give us the probability distribution value for specific independent events.

We can get the probability value of definite occurrences of events in the specified interval. Let’s consider ‘x’ as the mean value for the distribution, then with the help of the Poisson distribution. Poisson distribution is named after the French mathematician Simeon Denis Poisson.

R Language provides four in-built functions of Poisson distribution, and they are as follows:

  • dpois
  • ppois
  • qpois
  • rpois

The formula of Poisson distribution is as follows:

4 In-built Functions of Poisson distribution:


dpois(k, λ, log)


ppois(q, λ, lower.tail, log)


rpois(q, λ)


qpois(q, λ,lower.tail,log)

a) dpois:

  • When we use the dpois function in RStudio, it will return the value of the probability density of a random variable that can be within the number of events and in the estimated range of mean.
  • Syntax of dpois is as follows:
dpois(x, mean)
Description of above parameters:


dpois = poisson distribution function
x = number of events
mean = mean value of the event


                        OR


dpois(k, λ, log)


Description of above parameters:
dpois = Poisson distribution function
k = total number of events that occurred in an event
λ = λ is the mean value per interval.
log = If it is TRUE, then the function will return probability in the form of a log.

EXAMPLE: Let’s look at an example of dpois to understand the function better.

CODE 1:

# POISSON DISTRIBUTION IN R PROGRAMMING
# dpois function
# Example 1:


data <- dpois(2,4)
print(data)

OUTPUT 1:

POISSON DISTRIBUTION IN R PROGRAMMING

CODE 2:

# POISSON DISTRIBUTION IN R PROGRAMMING
# dpois function
# Example 2:


data <- dpois(8,8)
print(data)

OUTPUT 2:

POISSON DISTRIBUTION IN R PROGRAMMING

b) ppois:

  • When we use the ppois function in RStudio, it will return the value of the cumulative probability function.
  • In short, the ppois function will calculate the probability of a random variable that can be equal to or less than that number.
  • Syntax of ppois function is as follows:
ppois(q, λ, lower.tail, log)


Description of above parameters:


ppois = poison distribution function
q = a total number of events that occurred in an event
λ = λ is the mean value per interval.
lower.tail = If the situation comes out to be TRUE, then the left tail is considered; otherwise, if it is FALSE, then the right tail is considered.
log = If it is TRUE, then the function will return probability in the form of a log.

EXAMPLE:

CODE 1:

# POISSON DISTRIBUTION IN R PROGRAMMING
# ppois function
# Example 1:


data <- ppois(2,4)
print(data)

OUTPUT 1:

POISSON DISTRIBUTION IN R PROGRAMMING

CODE 2:

# POISSON DISTRIBUTION IN R PROGRAMMING
# ppois function
# Example 2:


data <- ppois(8,8)
print(data)

OUTPUT 2:

POISSON DISTRIBUTION IN R PROGRAMMING

c) rpois:

  • When we use the rpois function in RStudio, it will return the value of the random number, following a constant interval of the mean value.
  • Syntax of rpois is as follows:
rpois(q, λ)


Description of above parameters:


rpois = poison distribution function
q = total number of events that occurred in an event
λ = λ is the mean value per interval.

EXAMPLE 1:

CODE 1 :

# POISSON DISTRIBUTION IN R PROGRAMMING
# rpois function
# Example 1:


data <- rpois(2,4)
print(data)

OUTPUT 1:

POISSON DISTRIBUTION IN R PROGRAMMING

EXAMPLE 2:

CODE 2:

# POISSON DISTRIBUTION IN R PROGRAMMING
# ppois function
# Example 2:


data <- rpois(8,8)
print(data)

OUTPUT 2:

POISSON DISTRIBUTION IN R PROGRAMMING

d) qpois:

  • Using the qpois function in RStudio will work on the quantile probability distribution of all the data values together.
  • Quantile serves the data points into equal parts for the data to have equal probabilities.
  • Syntax of qpois() function is as follows:
qpois(q, λ,lower.tail,log)


Description of above parameters:
qpois = poisson distribution function
q = total number of events that occurred in an event
λ = λ is the mean value per interval.
log = If it is TRUE, then the function will return probability in the form of a log.

EXAMPLE 1:

CODE 1:

# POISSON DISTRIBUTION
# qpois function
# Example 1:


x <- c(0.01, 0.05, 0.1, 0.2)
qpois(x, 2)
qpois(x, 4)

OUTPUT 1:

POISSON DISTRIBUTION IN R PROGRAMMING

EXAMPLE 2:

CODE 2:

# POISSON DISTRIBUTION
# qpois function
# Example 2:


x <- c(0.01, 0.05, 0.1, 0.2)
qpois(x, 8)
qpois(x, 8)

OUTPUT 2:

POISSON DISTRIBUTION IN R PROGRAMMING

CONCLUSION:

It was all about the Poisson distribution in R programming. We studied the 4 different Poisson functions in detail in R programming.