Navya
Navya

Reputation: 287

How to calculate arrival rate per hour using poisson distribution in R?

I have a data frame with 66K rows and 4 columns i.e, customer ID, Customer checkin time,customer checkin hour and customer checkout time.

First 6 rows of the data:
cust_ID  cust_checkin_time      cust_checkout_time        checkin hour
12345    2019-01-01 07:02:50    2019-01-01 07:23:22        07AM_08AM
65789    2019-01-01 07:22:15    2019-01-01 07:26:02        07AM_08AM
90876    2019-01-01 07:25:21    2019-01-01 07:35:27        07AM_08AM
34567    2019-01-01 07:27:22    2019-01-01 07:38:56        07AM_08AM
36754    2019-01-01 07:44:41    2019-01-01 07:55:20        07AM_08AM
59876    2019-01-01 07:45:10    2019-01-01 07:58:42        07AM_08AM

I want to know arrival rate per hour to predict wait time using poisson distribution.

I am not able to calculate lambda i.e, arrival rate per hour.How to calculate that using poisson distribution or any other method.

Please,help me through this.I have spent almost one week time on searching google but i did not get any satisfied answers.

Upvotes: 2

Views: 712

Answers (1)

Martin Gal
Martin Gal

Reputation: 16988

First of all: That's not exactly a Stack Overflow question.

  • Assuming your customers arrive between 7 am and 7 pm, i.e. for 12 hours.
  • Count the customers per hour:
check-in hour   num_customer
 7 am -  8 am      10
 8 am -  9 am       7
10 am - 11 am      11
     ...
 6 pm -  7 pm       6

An estimator for lambda is given by the summarising your customers (10+7+11+...+6) and divide this by the number of observations (number of check-in hours, i.e. 12).


Using dplyr:

data %>%
  count(checkin_hour) %>%
  summarise(lamba=sum(n)/n())

gives your desired output.

Upvotes: 1

Related Questions