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.


Related Topics

Pie Charts in R Programming

R programming has various libraries to plot various types of charts and graphs. A pie chart is a circular statistical chart or graph, which is divided into slices to represent the numerical...

4 minutes read.

First R Program

First  Hello World R Program As a convention, our first R program will be the “Hello World!” program. We can run our R program either at R command prompt or we...

3 minutes read.

Scatter Plot in R Programming

A Scatter plot is a type of dispersion graph built to represent the various data points of variables. A Scatter plot is also known as a scatter graph or scattergram.  A scatter plot is used...

4 minutes read.

R If Else Statement

If statement It is the most simple decision-making statement. It checks the condition if the condition is true then only it will execute the block of statements written in the ‘if...

2 minutes read.

Binomial Distribution in R Programming

In this article, we will talk about the Binomial distribution in R programming. The binomial distribution is a type of probability distribution. As it is a discrete distribution, it will...

3 minutes read.

Measures of Central Tendency in R Programming

Central Tendency or CT is one of the features of descriptive statistics. The Central tendency will let us know how the various groups of data are clustered around the central...

4 minutes read.

R Inheritance

One the main concept of object oriented programming is inheritance which allows us to define a new class of existing classes. This means that we can derive new classes from...

5 minutes read.

How to create Histograms in R

R Histograms A Histogram is the graphical representation of the distribution of numeric data. It takes only one numeric variable as input. The variable is cut into several bars (also called...

2 minutes read.

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...

3 minutes read.

R Functions

In programming, a function is a group of instructions that you want to use repeatedly, because of their complexity, are better self-contained in sub-program and called when needed. Hence, we can...

4 minutes read.

Normal Distribution in R Programming

In statistics, the normal distribution is a type of probability function. Normal distribution tells the user about the distribution of data values in the dataset. It is a very important...

3 minutes read.

R Line Graphs

Line graph or line chart is a graph that connects a series of points by drawing segments between them. A line graph represents the relationship between 2 variables. These points...

2 minutes read.

R Pie Charts

R programming language provides many numbers of libraries to create charts and graphs. A pie-chart is a representation of data as slices of a circle with different colors representing counts...

2 minutes read.

R Data Types

Data types are used to define the size and type of the variable. In R, there is no need to declare a variable as some data types. The variables are...

4 minutes read.

R Operators

A symbol that tells the compiler to perform specific mathematical or logical operations is called operator. R language supports mainly 5 different types of operators, which are listed below: Arithmetic...

3 minutes read.

R JSON File

JSON stands for JavaScript Object Notation. It is a lightweight format for storing and transporting data. JSON file is often used when data is sent from a server to a...

2 minutes read.

R Excel Files

Microsoft Excel is the spreadsheet program which stores data in the .xls and .xlsx format. R has the facility to read directly from these files using some excel specific packages....

2 minutes read.

Analysis of Covariance in R Programming

Analysis of Covariance can also be named ANCOVA. We know that we use the concept of regression analysis for creating models which can explain the effect of the variation in...

2 minutes read.

R Basic Data Types

Data types are used to define the size and type of the variable. In R, there is no need to declare a variable as some data types. The variables are...

4 minutes read.

Introduction to R Programming

What is R Programming? R is a programming language which provides an environment for software used for statistical analysis, graphics representation and reporting. It possesses an extensive catalog of...

4 minutes read.