-
Notifications
You must be signed in to change notification settings - Fork 0
/
_054_poisson_realworld.R
41 lines (32 loc) · 1.15 KB
/
_054_poisson_realworld.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Filename: _054_poisson_realworld.R
# Title: Poisson Distribution Example - Number of Calls to a Call Center
# Author: Raghava | GitHub: @raghavtwenty
# Date Created: June 23, 2024 | Last Updated: June 23, 2024
# Language: R | Version: 4.4.0
# PROBLEM
# We consider a real-world scenario where the number of calls received by a call center
# in an hour follows a Poisson distribution with an average rate of 15 calls per hour.
# Parameters for the Poisson distribution
lambda = 15 # Average rate (calls per hour)
# Number of samples to generate
num_samples = 1000
# Generate random number of calls using the Poisson distribution
num_calls = rpois(num_samples, lambda = lambda)
# Display the first few generated number of calls
print(head(num_calls))
# Plot the histogram of the generated number of calls
hist(num_calls,
breaks = 30,
col = "lightblue",
border = "white",
main = "Poisson Distribution of Number of Calls to a Call Center",
xlab = "Number of Calls",
ylab = "Frequency"
)
# Add the theoretical density line
x_vals = 0:max(num_calls)
points(x_vals,
dpois(x_vals, lambda = lambda) * num_samples,
col = "red",
pch = 16
)