Rows: 15 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (2): PatientID, TreatmentMinutes
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Hour Patients
Min. : 1.00 Min. :16.00
1st Qu.: 5.75 1st Qu.:19.75
Median :10.50 Median :23.50
Mean :10.50 Mean :24.10
3rd Qu.:15.25 3rd Qu.:28.25
Max. :20.00 Max. :35.00
Determine whether a Poisson distribution is appropriate.
##Interpretation:
The mean number of arrivals is 24.1 and the variance is approximately 31.46. For a Poisson distribution, the mean and variance should be approximately equal. Although the variance is somewhat larger than the mean, the values are reasonably close, so a Poisson distribution may be an appropriate model for the patient arrivals.
Estimate the arrival rate parameter.
lambda <-mean(arrivals_data$Patients)lambda
[1] 24.1
##Interpretation:
The estimated arrival rate is 24.1 patients per hour, meaning the hospital receives approximately 24 patients per hour on average.
Calculate the probability of more than 30 arrivals in an hour.
In the observed data, 15% of the hours had more than 30 patient arrivals. Using a Poisson distribution with an estimated arrival rate of 24.1 patients per hour, the probability of having more than 30 arrivals in an hour is approximately 10%. Therefore, according to the Poisson model, there is about a 10% chance that more than 30 patients will arrive in a given hour.
PatientID TreatmentMinutes
Min. : 1.0 Min. :19.00
1st Qu.: 4.5 1st Qu.:28.00
Median : 8.0 Median :36.00
Mean : 8.0 Mean :36.07
3rd Qu.:11.5 3rd Qu.:44.50
Max. :15.0 Max. :55.00
Visualize the distribution.
hist(treatments_data$TreatmentMinutes,main ="Distribution of Treatment Times",xlab ="Treatment in Minutes",ylab ="Frequency")
##Interpretation:
The histogram shows that treatment times are concentrated around 30–40 minutes. The distribution is not perfectly bell-shaped, but it appears roughly symmetric with no obvious extreme outliers. Since the sample contains only 15 observations, it is difficult to determine normality from the histogram alone.
Determine whether a Normal distribution is reasonable.
qqnorm(treatments_data$TreatmentMinutes,main ="Q-Q Plot of Patient Treatment Times")qqline(treatments_data$TreatmentMinutes)
##Interpretation:
Based on the Q-Q plot, a Normal distribution appears to be reasonable for the treatment times. Most of the data points fall close to the reference line, with only small deviations at the tails. Therefore, the treatment times can reasonably be modeled using a Normal distribution.
Calculate the probability that treatment exceeds 45 minutes.
prob_that_trea_45 <-pnorm(45, mean =36.06667, sd =11.02897, lower.tail =FALSE )prob_that_trea_45
[1] 0.2089736
##Interpretation:
Based on the Normal distribution model, the probability that a patient’s treatment time exceeds 45 minutes is approximately 20.9%. This means that about 21% of treatments are expected to take longer than 45 minutes. This is consistent with the histogram, where most treatment times are concentrated around 30–40 minutes.
#Part C: Simulation
Simulate one month of arrivals.
n =720# Simulationset.seed(12345)# Simulate gsimulated_arrival <-rpois(n =720,lambda =24.1)simulated_arrival
Based on the Poisson model, the expected daily patient demand is approximately 578 patients. The simulation estimates the average daily demand using 30 days of simulated arrivals. The simulated average should be close to the theoretical expected value, although small differences may occur due to random variation.
Recommend staffing improvements.
# Maximum daily arrivalsmax(daily_arrivals)
[1] 636
# Minimum daily arrivalsmin(daily_arrivals)
[1] 548
# Standard deviation of daily arrivalssd(daily_arrivals)
Min. 1st Qu. Median Mean 3rd Qu. Max.
329.4 342.6 351.0 353.0 363.7 382.3
# Average daily treatment workloadmean(daily_treatment_hours)
[1] 352.9724
# Maximum daily treatment workloadmax(daily_treatment_hours)
[1] 382.3067
##Interpretation:
Based on the simulation results, the hospital is expected to receive approximately 578 patients per day. However, daily arrivals vary, with a minimum of 548 patients and a maximum of 636 patients. The standard deviation of approximately 23.89 patients shows that demand changes from day to day.
Based on these results, the hospital could improve staffing by:
Planning staffing around the expected daily demand while considering possible fluctuations.
Maintaining additional staff capacity during high-demand periods to reduce patient waiting times.
Considering average treatment duration when estimating staffing needs, rather than relying only on patient arrival counts.
Monitoring hourly arrival patterns to identify peak periods and adjust staff schedules accordingly.
The estimated daily treatment workload can also help the hospital understand how much treatment time may be required. However, additional information about staff availability, patient severity, and treatment resources would be needed to determine the exact number of staff required.