Poisson Distribution in R – Easy Reference

Filed Under: R Programming
Poisson Distribution In R

Hello, readers! In this article, we will be focusing on Poisson Distribution in R programming, in detail.

So, let us begin!!


First, what is Poisson Distribution?

Before diving deep into the concept of Poisson Distribution, let us first understand its emergence with respect to statistics here.

As we all know, whenever we come across the term statistics, the first thing that comes to our mind is distribution of data.

Yes, you are right!! Distribution of data enables us to understand the way our data is scattered with respect to the mean or any other statistical measure. There are various kinds of statistical distributions such as–

Today, we will be having a look at Poisson Distribution.

Poisson Distribution deals with the probability distribution of data values taking the mean into consideration. That is, it estimates the probability value for a set of cases with specific trails or events that happens at a customized yet constant mean value.

To be more precise, it gives us the value of probability distribution for some specific independent events.

Consider ‘x’ as the mean interval for the distribution, then poisson distribution would help us with the probability value of having certain occurrences of events in specific interval.

Specifically, in R programming, we would be understanding the below functions with respect to Poisson Distribution–

  • dpois() function
  • ppois() function
  • qpois() function
  • rpois() function

Let us move ahead with this.


1. R dpois() function

R dpois() function provides us with the probability density value for a set of events in a particular interval. Of course, these intervals share a constant (customized) mean value passed to the function as shown below.

Have a look at the below syntax!

dpois(x, mean)
  • x: number of successful trails/events
  • mean: The value of mean for the entire set of trails or events.

The dpois() function returns the probability density of a random variable that may be available in the estimated range of the mean and within the number of trails.

Example:

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

Output:

To interpret, the dpois() function here returns 0.09 as the probability value i.e. 0.09 is the probability that we may find a random variable within 4 successful events and 2 as the range of mean.

0.09022352

2. R ppois() function

R ppois() function helps us estimate the cumulative probability value for a set of successful trails. Here, as a result, we get the probability of occurrence of a random number whose estimated value is less than or equal to the value in the function.

Example:

In this example, we tend to find the probability of the data value to be less than or equal to the number with a constant mean of 2.

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

Output:

0.947347

3. R rpois() function

R rpois() function as the name suggests, calculates the random numbers that follow Poisson distribution i.e. follow a constant mean interval.

Example:

Here, rpois() function generates 4 random numbers that belong to the range of mean (2) and follow poisson distribution.

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

Output:

0 1 3 4

4. R qpois() function

R qpois() function works on the quantile probability distribution of the data values altogether. Quantiles serve a data points which distribute the graph into equal intervals for the data to have equal probabilities.

Example:

In this example, we have created a sequence of numbers with the difference of 0.1 using seq() function. Further, we have made use of qpois() function to generate the quantiles or data points that will divide the graph into equal intervals so that it has equal probabilities.

info <- seq(0,1,by = 0.1)

data <- qpois(info,2)
print(data)

Output:

0   0   1   1   1   2   2   3   3   4 

Conclusion

By this, we have come to the end of this topic. Feel free to comment below, in case you come across any question.

For more such posts related to R programming, stay tuned and till then, Happy Learning!! 馃檪

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content