Poisson Probability Distribution Using R

 

Experiment

Poisson Probability Distribution Using R

1. Aim

To study and implement the Poisson probability distribution in R by calculating individual and cumulative probabilities, generating the probability distribution, finding its mean and variance, and visualizing the distribution.


2. Objectives

After completing this experiment, students should be able to:

  1. Understand the concept and characteristics of the Poisson distribution.
  2. Identify the parameter of a Poisson distribution.
  3. Calculate the probability of a specified number of events manually.
  4. Calculate Poisson probabilities using R.
  5. Calculate cumulative probabilities.
  6. Generate the complete Poisson probability distribution.
  7. Calculate the mean, variance, and standard deviation.
  8. Visualize and interpret the Poisson distribution.

3. Theory

3.1 Poisson Distribution

The Poisson distribution is a discrete probability distribution used to model the number of times an event occurs in a fixed interval of time, distance, area, or volume, when the events occur independently and at a relatively constant average rate.

Examples include:

  • Number of customers arriving at a bank in one hour
  • Number of calls received by a call center in one minute
  • Number of defects in a length of manufactured material
  • Number of accidents at a particular intersection in a day
  • Number of emails received in an hour

If XX represents the number of occurrences of an event in a fixed interval, then:

X∼Poisson(λ)X\sim Poisson(\lambda)

where λ\lambda is the average number of occurrences in that interval.


3.2 Conditions for Poisson Distribution

A Poisson distribution is appropriate when:

  1. The number of occurrences is counted in a fixed interval.
  2. Events occur independently.
  3. The average rate of occurrence is approximately constant.
  4. Two events do not occur at exactly the same instant in the theoretical model.
  5. The probability of an occurrence in a very small interval is proportional to the size of that interval.

3.3 Poisson Probability Formula

The probability of exactly xx occurrences is:

P(X=x)=e−λλxx!P(X=x)=\frac{e^{-\lambda}\lambda^x}{x!}

where:

  • x=0,1,2,…x=0,1,2,\ldots
  • λ\lambda = average number of occurrences
  • e≈2.71828e\approx2.71828
  • x!x! = factorial of xx

4. Problem Statement

A computer server receives an average of 4 requests per minute.

Assume that the requests occur independently and the average rate remains constant.

Let:

X=number of requests received in one minuteX=\text{number of requests received in one minute}

Therefore:

X∼Poisson(4)X\sim Poisson(4)

Using the Poisson distribution:

  1. Calculate the probability of receiving exactly 3 requests in one minute.
  2. Calculate the probability of receiving at most 3 requests in one minute.
  3. Calculate the probability of receiving at least 3 requests in one minute.
  4. Generate the complete probability distribution for X=0,1,…,12X=0,1,\ldots,12.
  5. Calculate the mean, variance, and standard deviation.
  6. Plot the Poisson probability distribution.
  7. Interpret the results.

5. Manual Calculation

5.1 Probability of Exactly 3 Requests

Given:

λ=4\lambda=4

and

x=3x=3

Using the Poisson formula:

P(X=3)=e−4433!P(X=3)=\frac{e^{-4}4^3}{3!}

Since:

43=644^3=64

and

3!=63!=6

we get:

P(X=3)=e−4(64)6P(X=3)=\frac{e^{-4}(64)}{6}

Using:

e−4≈0.0183156e^{-4}\approx0.0183156

we get:

P(X=3)=0.0183156×646P(X=3)=\frac{0.0183156\times64}{6}
P(X=3)≈0.195366
P(X=3)\approx0.195366

Therefore:

P(X=3)≈0.1954\boxed{P(X=3)\approx0.1954}

or approximately 19.54%.


5.2 Probability of At Most 3 Requests

"At most 3" means:

P(X≤3)P(X\leq3)

Therefore:

P(X≤3)=P(X=0)+P(X=1)+P(X=2)+P(X=3)P(X\leq3) = P(X=0)+P(X=1)+P(X=2)+P(X=3)

Using the Poisson formula:

For X=0X=0

P(X=0)=e−4400!P(X=0)=\frac{e^{-4}4^0}{0!}
=0.0183156
=0.0183156

For X=1X=1

P(X=1)=e−4411!P(X=1)=\frac{e^{-4}4^1}{1!}
=0.0732626
=0.0732626

For X=2X=2

P(X=2)=e−4422!P(X=2)=\frac{e^{-4}4^2}{2!}
=0.146525
=0.146525

For X=3X=3

P(X=3)=0.195366P(X=3)=0.195366

Therefore:

P(X≤3)=0.0183156+0.0732626+0.146525+0.195366P(X\leq3) = 0.0183156+0.0732626+0.146525+0.195366
P(X≤3)≈0.43347
\boxed{P(X\leq3)\approx0.43347}

or approximately 43.35%.


5.3 Probability of At Least 3 Requests

"At least 3" means:

P(X≥3)P(X\geq3)

Using the complement:

P(X≥3)=1−P(X≤2)P(X\geq3)=1-P(X\leq2)

We have:

P(X≤2)=P(X=0)+P(X=1)+P(X=2)P(X\leq2) = P(X=0)+P(X=1)+P(X=2)
=0.0183156+0.0732626+0.146525
=0.0183156+0.0732626+0.146525

=0.2381038
=0.2381038

Therefore:

P(X≥3)=1−0.2381038P(X\geq3)=1-0.2381038
P(X≥3)≈0.761896
\boxed{P(X\geq3)\approx0.761896}

or approximately 76.19%.


6. Mean, Variance and Standard Deviation

One important property of the Poisson distribution is that its mean and variance are both equal to λ\lambda.

Mean

μ=λ\mu=\lambda

For the given problem:

μ=4\boxed{\mu=4}

Variance

σ2=λ\sigma^2=\lambda

Therefore:

σ2=4\boxed{\sigma^2=4}

Standard Deviation

σ=λ\sigma=\sqrt{\lambda}

Therefore:

σ=4\sigma=\sqrt{4} σ=2\boxed{\sigma=2}

Thus:

Measure        Value
Mean            4
Variance            4
Standard deviation            2

7. R Functions for Poisson Distribution

R provides four important functions for the Poisson distribution:

R FunctionPurpose
dpois()        Probability of exactly xx occurrences
ppois()        Cumulative probability
qpois()        Quantile for a given probability
rpois()        Generates random observations

For example:

dpois(3, lambda = 4)

calculates:

P(X=3)P(X=3)

Similarly:

ppois(3, lambda = 4)

calculates:

P(X≤3)P(X\leq3)

8. Program

# Poisson Probability Distribution

# Parameter
lambda <- 4

# Possible number of requests
x <- 0:12


# Probability distribution

probability <- dpois(x, lambda = lambda)

distribution <- data.frame(
    Requests = x,
    Probability = probability
)

print(distribution)


# Probability of exactly 3 requests

p_exactly_3 <- dpois(3, lambda = lambda)

cat("\nProbability of exactly 3 requests =",
    p_exactly_3, "\n")


# Probability of at most 3 requests

p_at_most_3 <- ppois(3, lambda = lambda)

cat("Probability of at most 3 requests =",
    p_at_most_3, "\n")


# Probability of at least 3 requests

p_at_least_3 <- 1 - ppois(2, lambda = lambda)

cat("Probability of at least 3 requests =",
    p_at_least_3, "\n")


# Mean

mean_value <- lambda


# Variance

variance <- lambda


# Standard deviation

standard_deviation <- sqrt(lambda)

cat("\nMean =", mean_value, "\n")
cat("Variance =", variance, "\n")
cat("Standard Deviation =",
    standard_deviation, "\n")


# Plot the Poisson distribution

barplot(probability,
        names.arg = x,
        main = "Poisson Probability Distribution",
        xlab = "Number of Requests per Minute",
        ylab = "Probability")

9. Expected Result

Requests  Probability
1         0 0.0183156389
2         1 0.0732625556
3         2 0.1465251111
4         3 0.1953668148
5         4 0.1953668148
6         5 0.1562934519
7         6 0.1041956346
8         7 0.0595403626
9         8 0.0297701813
10        9 0.0132311917
11       10 0.0052924767
12       11 0.0019245370
13       12 0.0006415123

Probability of exactly 3 requests = 0.1953668 
Probability of at most 3 requests = 0.4334701 
Probability of at least 3 requests = 0.7618967 

Mean = 4 
Variance = 4 
Standard Deviation = 2 

The program also generates the probability of each possible number of requests from 0 to 12 and displays the corresponding Poisson distribution using a bar plot.



10. Interpretation

From the results:

  • The probability of receiving exactly 3 requests in one minute is approximately 19.54%.
  • The probability of receiving at most 3 requests is approximately 43.35%.
  • The probability of receiving at least 3 requests is approximately 76.19%.
  • The expected number of requests per minute is 4.
  • The variance is also 4, which is a characteristic property of the Poisson distribution.
  • The standard deviation is 2.

The bar plot shows that the probabilities are concentrated around the average value of 4 requests per minute.


11. Result

The Poisson probability distribution was studied and implemented using R. The probability of exactly 3, at most 3, and at least 3 requests was calculated manually using the Poisson probability formula and verified using R. The complete probability distribution was generated and represented graphically. The mean, variance, and standard deviation were also calculated and interpreted.

Comments

Popular posts from this blog

Statistical Methods Lab ( R Language) PCCBL308 Semester 3 KTU BTech CB and CU 2024 Scheme - Dr Binu V P

Programs in R - using control statements - Assignment 2

Programs to try using Functions in R - Assignment 3