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

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 Tutorial

Introduction to R Programming R is nothing but a programming language, also a free software environment. This software used for predictive analysis, statistical analysis, graphical representation, data modeling, and reporting. R...

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

R Variables, Constants and Reserved Words

R Variables Variables are very similar to an open box, where you can put any value of your wish. We can change the values as well. Variables are used to store...

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.

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.

Clustering in R Programming

The clustering technique is an unsupervised machine learning in R programming. Before discussing clustering techniques, let's have a look at what unsupervised machine learning is?  Unsupervised learning is training the model with...

3 minutes read.

Linear Regression in R Programming

Linear Regression is an unsupervised machine learning algorithm in R programming. Linear Regression is a type of regression analysis that shows the relationship between two or more variables. And one...

3 minutes read.

R Date and Time

R provides very large range of capabilities to deal with times and dates. Generally, dates are internally stored as integers, and depending on the operations we will need, we could...

3 minutes read.

Various types of Charts in R Programming

As we know, R Language is mostly used for analyzing the data and statistics purposes to represent our data graphically & pictorially in R studio. Charts and graphs are plotted in...

4 minutes read.

Logistic Regression in R Programming

Logistic Regression is a classification supervised machine learning algorithm in R programming. Logistic Regression can also be termed Binomial Logistic Regression, Binary Logistic Regression, or Logit Model. Logistic Regression is...

4 minutes read.

How to make Boxplots in R

R Boxplots Boxplot is a measure of how well the data is distributed in a data set. It is used to give a summary of one or several numeric variables. The...

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

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

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.

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.