aim of W8bus
To provide users with estimated waiting times at bus stops based on input data such as the hourly number of buses, passengers, and queue size when arriving, aiding in more informed commute planning.
Description of W8Bus
W8Bus, a waiting time estimator designed to assist commuters in planning their journeys more effectively by providing estimated waiting times at bus stops. It takes into account input data such as the hourly number of buses, passengers, and queue size when arriving, utilizing this information to calculate rough estimates of wait times. While the estimates are based on these inputs, it's important to note that factors like traffic conditions, weather and unexpected delays can affect actual wait times. Nevertheless, the app serves as a helpful tool for commuters, offering them a clearer picture of what to expect when waiting for the bus. Users are required to input the number of desired buses per hour and the number of people who come and take that particular bus per hour, e.g., If the bus company runs that particular bus every ten minutes, and the average number of people who take this bus hourly is 60, queue size is 5 excluding yourself is 5, then enter theses numbers 6, 60 and 5 in the first, second and third text field, respectively.
How to estimate the waiting time
Estimating the waiting time until the bus arrives after you reach the bus stop is essential. How long do you need to wait for the next bus? You can count how many people are queuing (n1), but you don't know how many people will come until the bus arrives (N). The number of people waiting between the inter-arrival time of the bus is n + N. The inter-arrival time of the bus is X = S + T, which is unknown. Here, S represents the time elapsed between the last bus arrival and the time you arrived at the bus stop, while T is the waiting time we want to infer.
We aim to determine how long we need to wait until the next bus arrives based on the number of people queuing at the bus stop.
We provide two models to infer the waiting time T based on whether the bus arrival process follows a Poisson or Erlang order 2 distribution.
In both models, the inference of the waiting time T is based on Bayesian analysis, considering the expected number of passengers showing up during the waiting time T.
What is the posterior PDF of T P(T = t|N = n2) given the number of waiting people showing up during the waiting time T? Thomas Bayes tells us how to tackle this problem.
P(T = t|N = n2) = P(T = t) * P(N = n2|T = t) / P(N = n2)
We provide three models depending on the bus arrival process: Model I assumes Poisson bus arrivals, while Model II and III assume Erlang bus arrivals. In each model, the prior probability density function (PDF) is evaluated accordingly to calculate the marginal probability mass function (PMF) and posterior PDF. Finally, using the conditional PDF of the posterior to calculate the least mean square estimator to estimate the expected waiting time. We assumed that the arrival of each passenger is independent of each other. Specifically, when one group of people with more than one person arrives, it is counted as one passenger.
Model I (Poisson bus) :
Inter-arrival time of a bus S + T is distributed as an Erlang order 1, namely a Poisson random variable with parameter lambda. Suppose people arriving at the bus stop are also Poisson with parameter mu. According to this assumption, we can evaluate the denominator and numerator in the above equation to calculate the conditional posterior distribution of T given the passenger number showing up during the bus waiting time T. We use this posterior PDF to calculate conditional expectation. W8Bus calculates the mean waiting time and the mean plus or minus one standard deviation away from the mean in minutes using the equations shown below.
Prior PDF of waiting time is exponential: P(T = t) =λ exp(-λt)
Likelihood of the arriving passengers during this waiting time t: P(N = n2|T = t) = exp(-μt) * (μt)^n2 / n2!
Marginal PMF of the denominator: P(N = n2) = μ^n2 * λ / (μ + λ)^(n2 + 1)
Thus the conditional posterior PDF is : P(T = t|N = n2) = exp(-(μ + λ)t) * (μ + λ)^(n2 + 1) t^n2 / n2!
Conditional least mean square is: E[T|N = n2] = (n2 + 1) / (μ + λ)
Conditional variance: Var[T|N = n2] = (n2 + 1 ) / (μ + λ)^2
n2 = E[N] = μ/λ - n1=μ/λ0 - n1, where λ0 is a bus arriving rate and n1 is the queue size when arriving.
Model II (Erlang bus) :
The arrival of people is in a Poisson process, and a bus arrival is in an Erlang order 2 process. The remaining time T, after you arrive at the bus stop until the bus arrives, follows a Poisson or Erlang order 2 distribution. It depends on when you arrive at the bus stop. When you arrive in the first Poisson interval, T is distributed as Erlang with order 2, but when you arrive in the second Poisson interval, T is distributed as exponential. We assume your appearance at the bus stop, where the bus arrival process follows an Erlang order 2 distribution, is likely in the first Poisson interval when the queue size is small and in the second Poisson interval when the queue size is large, and apply the total probability theorem to evaluate P(T = t) and P(N = n2). W8Bus displays the mean waiting time plus or minus one standard deviation away from the mean in min using the equations shown below.
Prior PDF of waiting time is exponential or Erlang with order 2 equally likely: P(T = t) = p * λ * exp(-λt) + q * exp(-λt) * λ^2 * t, where p = λ / (2μ) * n1, and q = 1 - p, n1 is the queue size.
Likelihood of the arriving passengers during this waiting time t: P(N = n2|T = t) = exp(-μt) * (μt)^n2 / n2!
Marginal PMF of the denominator: P(N = n2) = μ^n2 * λ * [p / (μ + λ)^(n2 + 1) + q * λ* (n2 + 1) / (μ + λ)^(n2 + 2)]
Thus the conditional posterior PDF is : P(T = t|N = n2) = exp(-(μ + λ)t) * (μ + λ)^(n2+2) * t^n2 * (q * λ * t + p) / n2! / (p * (μ + λ) + q * λ * (n2 + 1) )
Conditional least mean square is: E[T|N = n2] = (n2 + 1) * (p * (μ + λ) + q * λ * (n2 + 2) ) / (μ + λ) / (p * (μ + λ) + q * λ * (n2 + 1) )
Conditional squared T is: E[T^2|N = n2] = (n2 + 2) * (n2 + 1) * (p * (μ + λ) + q * λ * (n2 + 3) / (μ + λ)^2 / (p * (μ + λ) + q * λ * (n2 + 1) )
Conditional variance: Var(T|N = n2) = E[T^2|N = n2] - E[T|N = n2]^2
n2 = E[N] = μ* 2/λ - n1 = μ * 2 / (2*λ0) - n1, where λ0 is a bus arriving rate and n1 is the queue size when arriving.
Model III (Erlang bus) :
The arrival of people is in a Poisson process, and a bus arrival is in an Erlang order 2 process. The remaining time T, after you arrive at the bus stop until the bus arrives, follows a Poisson or Erlang order 2 distribution. It depends on when you arrive at the bus stop. When you arrive in the first Poisson interval, T is distributed as Erlang with order 2, but when you arrive in the second Poisson interval, T is distributed as exponential. We assume your appearance at the bus stop, where the bus arrival process follows an Erlang order 2 distribution, is equally likely in the first or second Poisson interval, and apply the total probability theorem to evaluate P(T=t) and P(N=n2). W8Bus displays the mean waiting time plus or minus one standard deviation away from the mean in min using the equations shown below.
Prior PDF of waiting time is exponential or Erlang with order 2 equally likely: P(T = t) = 1/2 * λexp(-λt) (1 + λ * t)
Likelihood of the arriving passengers during this waiting time t: P(N = n2|T = t) = exp(-μt) * (μt)^n2 / n2!
Marginal PMF of the denominator: P(N = n2) = μ^n2 * λ^2 / 2 (μ + λ)^(n2 + 2) * ( n + 1 + μ + λ)
Thus the conditional posterior PDF is : P(T = t|N = n2) = exp(-(μ + λ)t) * (μ + λ)^(n2+2) * t^n2 * (λ * t + 1) / n2! / (λ(n21 + 2) + μ)
Conditional least mean square is: E[T|N = n2] = (n2 + 1) * (λ(n2 + 2) + μ + λ) / (μ + λ) / (λ(n2 + 1) + μ + λ)
Conditional variance: Var(T|N = n2) = (n2 + 1)(λ * (n2 + 3) + μ + λ) / (μ + λ) / (λ * (n2 + 1) + μ + λ)^2
n2 = E[N] = μ* 2/λ - n1 = μ * 2 / (2*λ0) - n1 = μ * 2 / (2*λ0) - n1, where λ0 is a bus arriving rate and n1 is the queue size when arriving.