BSc Thesis Applied Mathematics
The Inter-arrival Time between Consecutive Buses at Bus Stops
Huan Wu
Supervisor: Richard J. Boucherie
January 24, 2020
Department of Applied Mathematics
Faculty of Electrical Engineering,
Mathematics and Computer Science
Acknowledgement
I would like to express my sincere thanks and gratitude to my supervisor Professor Richard J. Boucherie for his professional guiding, generous support and encouragement throughout the whole process of doing this project and thesis writing. Honestly speaking, I cannot fulfil this project without his guidance and help.
I would also like to extend my gratitude to Rutger Mauritz, Weiting Cai and Di Zhuang for their kind help and support. Thank you for helping me whenever I have difficulties in programming. Besides, I would also like to thank my parents for their unconditional love and support to me without which I cannot go through this tough academic journey overseas.
In addition, I would also like to thank my cousin Xiaoping Wu for helping me about the
English writing. Thank you for helping me correct the grammar and typo mistakes in this
thesis. Last but not the least, my thanks also goes to Bram A.J. Jonkheer and other lovely
guys like Sven Dummer, Wisse van der Meulen whom I hang out with during the three
years of studying in University of Twente, who make the tough time joyful and fun.
The Inter-arrival Time between Consecutive Buses at Bus Stops
Huan Wu ∗ January 24, 2020
Abstract
It happens very often that a bus is delayed at a bus stop, leading to that passen- gers waste time waiting for the bus and bus companies receive a lot of complaints.
This real life problem becomes the source of my research project in this thesis. To get the arrival time of buses with more exactness and certainty will help much to enhance the working efficiency of companies and save time cost for passengers. The inter-arrival time between consecutive buses at bus stops is explored in four different models, namely Simple Gated Model, Complicated Gated Model, Exhaustive Model and Poisson Model. In the Simple Gated Model, the inter-arrival of time between buses is investigated through both theoretical analysis and discrete event simulation.
The results show that the difference between analytical values and simulation values is significantly small. In the other three models, the inter-arrival time between buses is worked out by simulating specific situations with certain variables controlled. In the Complicated Model, it shows that the inter-arrival time between buses is influ- enced by the number of passengers arriving per unit time. In the last two models, the inter-arrival time between buses has a similar change pattern with the arrival rate of passengers being the same.
More work is to be done in the study of Poisson Model in finding the inter-arrival time between buses. For example, for sake of convenience and being easy to handle, it is supposed that all passengers get on(or off) the bus just through one gate in my research, yet in actual life, passengers get on(or off) the bus trough two gates. The research to come could focus on the study of two gates case.
Keywords: Inter-arrival time between buses, Gated Model, Exhaustive Model, Poisson Model, arrival rate of passengers.
∗
Email: h.wu-3@student.utwente.nl
Contents
1 Introduction 4
2 Simple Gated Model 5
2.1 Problem Context . . . . 5
2.2 Assumption . . . . 5
2.3 Analysis . . . . 5
2.3.1 The Distribution of X n j . . . . 7
2.3.2 The Expectation of X n j . . . . 8
2.3.3 The Expectation of A j n . . . 10
2.4 Simulation . . . 10
2.4.1 Explanation of the Simulation . . . 11
2.4.2 Simulation Results . . . 11
3 Complicated Gated Model 12 3.1 Problem Context . . . 12
3.2 Assumptions . . . 13
3.3 Analysis . . . 13
3.3.1 The Distribution of X n j . . . 14
3.3.2 The Expectations of X n j and A j n . . . 15
3.4 Simulation . . . 15
4 Exhaustive Model 17 4.1 Motivation . . . 17
4.2 Problem Description . . . 17
4.3 Assumptions . . . 17
4.4 Simulation . . . 18
4.4.1 Explanation of the Simulation . . . 18
4.4.2 Simulation Results . . . 18
5 Poisson Model 19 5.1 Problem Description . . . 19
5.2 Assumptions . . . 19
5.3 Simulation . . . 19
5.3.1 Explanation of the Simulation . . . 19
5.3.2 Simulation Results . . . 19
6 Discussion 20 7 Appendix 1 23 8 Appendix 2 25 8.1 Derivations and Results of E(X i j ) . . . 25
8.1.1 E(X 0 j ) and E(X 1 j ) . . . 25
8.1.2 E(X 2 j ) . . . 25
8.1.3 E(X 3 j ) . . . 25
8.1.4 E(X 4 j ) . . . 26
8.2 Merging the case for 1 < j < n and j = n . . . 27
8.3 Derivations and Results of A j i . . . 27
8.3.1 E(A j 0 ) and E(A j 1 ) . . . 27
8.3.2 E(A j 2 ) . . . 27
8.3.3 E(A j 3 ) . . . 28
8.3.4 E(A j 4 ) . . . 28
9 Appendix 3 30 9.1 Flow Chart of Class Passenger Arrival(t, s) . . . 30
9.2 Flow Chart of Class Bus Arrival(t, s, b) . . . 30
9.3 Flow Chart of Class Pick Up(t, s, b) . . . 33
9.4 Flow Chart of Class Bus Departure(t, s, b) . . . 33
10 Appendix 4 34 10.1 Simulation Code of Avg(A j n ) for Simple and Complicated Gated Models . . 34
10.2 Recursion Code of E(A j n ) for Simple Gated Model . . . 39
10.3 Simulation Code of Avg(A j n ) for Exhaustive Model . . . 40
10.4 Simulation Code of Avg(A j n ) for Poisson Model . . . 46
1 Introduction
Nowadays, public transportation has become the main way of travelling which is good both environmentally and financially. Although the arrival time of a bus is usually available on bus apps and other online applications, it often happens that a bus maybe delayed. This might be caused by the large number of passengers waiting in the stop. In this sense, knowing the exact arriving time of the bus is highly useful and important to both the bus companies and the passengers.
In this thesis, the research question that ‘what is the inter-arrival time between consecutive buses at an arbitrary bus stop?’ will be explored and answered within the framework of four different theoretical models, namely Simple Gated Model, Complicated Gated Model, Exhaustive Model and Poisson Model. In the first model, the research question will be ex- plored by both theoretical analysis and simulation results, while in the other three models, it will only be answered numerically by simulations.
The four models are ranked from most simple to most sophisticated, with the last one
most resembling the real life case. The reason why analytical solutions are provided only
in the first model is that the other three models are more complicated (than the first one),
therefore no analytical solutions can be derived. The simulation code for the first model
is the basis of the other three models.
2 Simple Gated Model
2.1 Problem Context
Consider bus-b on a one-directional road at stop-n, where b, n ∈ N = {0, 1, 2...}. At each stop, passengers arrive according to a Poisson Process with the same rate λ. A bus that arrives at a stop will allow all passengers waiting there to board the bus, i.e. the bus has unlimited capacity. But gated discipline is applied, which means a bus does not pick up the passengers who arrive during its halting time and these passengers will wait for the next bus. The halting time of the bus is proportional to the number of passengers boarding the bus with the proportional factor being α. Actually, α is the average time that a pas- senger takes to get on the bus. At stop-0, buses arrive according to a deterministic time, i.e. every T time, a bus arrives. The travel time between each stop is also deterministic.
Let the travel time be D. To initialise the system, it is supposed that before time nD, no passengers arrive at stop-n, which means at each bus stop, the arrival process of passengers starts after bus-0 arrives. This results in a fact that the halting time of bus-0 is 0 at any stop.
2.2 Assumption
When a bus arrives at a bus stop, the previous bus has already finished its halting proce- dure, i.e. different buses will not meet each other at the same bus stop. In other words, buses will not pile up. It might be considered that this assumption is unrealistic or even
“weird". The reason why we make this simplified assumption is that it can save us from taking into account the complex situations of buses piling up or overtaking each other in the real life case.
2.3 Analysis
To get some idea of how the system works, we begin with analysing the first three buses (bus-0, 1, 2) from stop-0 to stop-4, which can be seen as the preliminary tool for section 2.3.1. After this step, some structured pattern will be found, and then we will broaden our horizon to analyse an arbitrary bus-j with j ∈ Z + at an arbitrary stop-n with n ∈ N.
Let’s first introduce the following definitions:
Definition 1. For b, n ∈ N and w ∈ Z + ,
• X n b := the number of passengers waiting for bus-b at stop-n.
• X −w b := 0 .
• H n b := the halting time of bus-b at stop-n.
Definition 2. Let K be a random variable such that P (K = 0) = and P (K > 0) = 1−, where 0 < < 1. X ∼ P oisson(K) if P (X = x|K = k) = k x!
xe −k for x = 0, 1, 2...
Figure 1 shows the arrival and departure time of bus-0. We use one dot to represent
both arrival and departure time since the halting time of bus-0 is 0 at any stop.
Figure 1: The Arrival and Departure Time of Bus-0.
It follows that H i 0 = 0 and X i 0 = 0, where i ∈ {0, 1, 2, 3, 4}.
Then the arrival and departure time of bus-1 is going to be analysed. See figure 2, where the up and down arrow represent the arrival and departure time respectively.
Figure 2: The Arrival and Departure Time of Bus-1.
The following can be gained:
• X 0 1 ∼ P oisson(λT ) , and H 0 1 = αX 0 1 .
• X 1 1 ∼ P oisson λ(T + H 0 1 )
, and H 1 1 = αX 1 1 .
• X 2 1 ∼ P oisson λ(T + H 0 1 + H 1 1 )
, and H 2 1 = αX 2 1 .
• X 3 1 ∼ P oisson λ(T + H 0 1 + H 1 1 + H 2 1 )
, and H 3 1 = αX 3 1 .
• X 4 1 ∼ P oisson λ(T + H 0 1 + H 1 1 + H 2 1 + H 3 1 )
, and H 4 1 = αX 4 1 . Next, bus-2 is going to be analysed. See figure 3.
Figure 3: The Arrival and Departure Time of Bus-2.
The distribution of X i 2 with i ∈ {0, 1, 2, 3, 4} has a Poisson form, where the parameters
could be random variables, since the arrival process of passengers is a Poisson Process with
rate λ. Here we want to explain how to find the parameter for X i 2 . We take X 0 2 as an example. The parameter for X 0 2 = λ∗ the time interval in which new passengers arrive.
New passengers refer to passengers waiting for bus-2 at stop-0. Then the beginning point of this interval is the time at which the previous bus(i.e. bus-1) arrived at stop-0, because based on the gated discipline, passengers who arrive during the halting time of bus-1 will take bus-2 instead of bus-1. The ending point of that interval is the time at which bus-2 arrives at stop-2. Back to figure 2 and 3, the starting point of this interval is T and the ending point is 2T . Therefore, X 0 2 ∼ P oisson(λ(2T − T )) . We can use the same method to get the parameters for X 1 2 , X 2 2 , X 3 2 , X 4 2 . Then we have:
• X 0 2 ∼ P oisson(λT ) , and H 0 2 = αX 0 2 .
• X 1 2 ∼ P oisson
λ (2T +D+H 0 2 )−(T +D+H 0 1 )
⇒ X 1 2 ∼ P oisson λ(T +H 0 2 −H 0 1 ) , and H 1 2 = αX 1 2 .
• X 2 2 ∼ P oisson
λ (2T + 2D + H 0 2 + H 1 2 ) − (T + 2D + H 0 1 + H 1 1 )
⇒ X 1 2 ∼ P oisson λ(T + H 0 2 + H 1 2 − H 0 1 − H 1 1 )
, and H 2 2 = αX 2 2 .
• X 3 2 ∼ P oisson
λ (2T + 3D + H 0 2 + H 1 2 + H 2 2 ) − (T + 3D + H 0 1 + H 1 1 + H 2 1 )
⇒ X 1 2 ∼ P oisson λ(T + H 0 2 + H 1 2 + H 2 2 − H 0 1 − H 1 1 − H 2 1 )
, and H 3 2 = αX 3 2 .
• X 4 2 ∼ P oisson
λ (2T +4D+H 0 2 +H 1 2 +H 2 2 +H 3 2 )−(T +4D+H 0 1 +H 1 1 +H 2 1 +H 3 1 )
⇒
X 4 2 ∼ P oisson λ(T + H 0 2 + H 1 2 + H 2 2 + H 3 2 − H 0 1 − H 1 1 − H 2 1 − H 3 1 )
(1) and H 4 2 = αX 4 2 .
• Note: the parameter for X i 2 is always positive since buses will not pile up by assump- tion.
2.3.1 The Distribution of X n j
Taking equation (1) X 4 2 ∼ P oisson λ(T + H 0 2 + H 1 2 + H 2 2 + H 3 2 − H 0 1 − H 1 1 − H 2 1 − H 3 1 ) an example, it can be observed that the parameter for X 4 2 contains the sum of the halting as time of bus-2 and the negative sum of the halting time of bus-1. For compactness sake, we introduce the following definition:
Definition 3. For j, w ∈ Z + and n ∈ N,
• Z n j := P n l=0 H l j .
• Z −w j := 0 .
• Z n 0 := 0 .
The distribution of X n 0 is too easy, so we will skip that and directly give the distribution of X n j based on definition 3, which is stated in the following theorem. Note that the parameter for X n j is always positive since we assume that buses will not pile up.
Theorem 1. X n j ∼ P oisson λ(T + Z n−1 j − Z n−1 j−1 ) , ∀j ∈ Z + and n ∈ N.
Proof. The distribution of X n j has a Poisson form since the arrival process of passengers is a Poisson Process with rate λ. Let I n j = [a, b] be the time interval during which passengers who will wait for bus-j at stop-n arrive. a is the time point at which bus-(j − 1) arrives at stop-n. Before bus-(j − 1) arrives at stop-n, it halted at stop-0, 1, 2...(n − 1). So the total halting time for it is P n−1 l=0 H l j−1 = Z n−1 j−1 . The travel time for it to reach stop-n is nD. Together with the fact that at time (j − 1)T , bus-(j − 1) departs from stop-0, we get a = (j − 1)T + nD + Z n−1 j−1 . Similarly, b is the time point at which bus-j arrives at stop-n and b = jT + nD + Z n−1 j . Therefore, I n j = [a, b] =[(j − 1)T + nD + Z n−1 j−1 , jT + nD + Z n−1 j ] . It follows that X n j ∼ P oisson(λ
I n j
) ⇒ X n j ∼ P oisson λ(b − a) ⇒ X n j ∼ P oisson λ(T + Z n−1 j − Z n−1 j−1 )
.
Actually, the distribution of X n j is summarized by starting from analysing bus-1 at stop-i, where i ∈ {0, 1, 2, 3, 4}. Readers who are interested in it can see Appendix 1 in detail.
2.3.2 The Expectation of X n j
Having gained the probability distribution of X n j , the expectations of the inter-arrival time between consecutive buses at bus stops may be obtained as follows. Let A j n :=the time between bus-j’s arriving and bus-(j − 1)’s arriving at stop n, where j ∈ Z + and n ∈ N.
There is a special relationship between E(X n j ) and E(A j n ), which will be explained in section 2.3.3. Therefore, E(X n j ) should be solved firstly and it is shown as follows:
E(X n j ) =
λT (1 + αλ) n if j = 1
E(X n−1 j ) + λ αE(X n−1 j ) − αE(X n−1 j−1 )
if 1 < j ≤ n
λT if j > n
(2)
Equation (2) is concluded from the expression of E(X i j ) , where i ∈ {0, 1, 2, 3, 4}. See derivations and results of E(X i j ) in section 8.1 in Appendix 2. Before proving that equation (2) is correct, let’s introduce the following theorem.
Theorem 2. Let X and Y be discrete random variables. If Z ∼ P oisson(aX + bY + c) with a ,b, c ∈ R and aX + bY + c > 0 with probability 1, then E(Z) = aE(X) + bE(Y ) + c.
Proof. Fubini’s Theorem [1] ensures that P y=∞ y=0 P x=∞
x=0 P (X = x, Y = y) = P x=∞
x=0
P y=∞
y=0
P (X = x, Y = y) , since P (X = x, Y = y) is non-negative.
Then we can show that E(Z) = E (E(Z | X, Y ) = P ∞ y=0 P ∞
x=0 E(Z | X = x, Y = y)P (X = x, Y = y) = P y=∞
y=0
P x=∞
x=0 (ax+by+c)P (X = x, Y = y) = P x=∞
x=0 ax P y=∞
y=0 P (X = x, Y = y) + P y=∞
y=0 by P x=∞
x=0 P (X = x, Y = y) + c P y=∞
y=0
P x=∞
x=0 P (X = x, Y = y) = P x=∞
x=0 axP (X = x)+ P y=∞
y=0 byP (Y = y)+c = aE(X)+bE(Y )+c i.e. E(aX+bY +c).
From now on, equation (2) is going to be split into three theorems and proved by making use of theorem 2.
Theorem 3. If j = 1, then ∀n ∈ N, E(X n j ) = E(X n 1 ) = λT (1 + αλ) n . Proof. We prove it by Mathematical Induction.
• Basis Step: for n = 0, definition 3 and theorem 1 imply X 0 1 ∼ P oisson(λT ) . So
E(X 0 1 ) = λT = λT (1 + αλ) 0 .
• Induction Step: take k ≥ 1 and k ∈ N, by definition 3 and theorem 1, we have X k 1 ∼ P oisson λ(T + Z k−1 1 ) ⇒ E(X k 1 ) = [using theorem 2] = λ T + E(Z k−1 1 )
. Assume for n = k, k ≥ 1 and k ∈ N, E(X k 1 ) = λT (1 + αλ) k ——(IH). Now we want to show that E(X k+1 1 ) = λT (1 + αλ) k+1 .
By definition 3 and theorem 1, we have X k+1 1 ∼ P oisson λ(T +Z k 1 ) = P oisson λ(T + Z k−1 1 + H k 1 ) = P oisson λ(T + Z k−1 1 + αX k 1 ) ⇒ E(X k+1 1 ) = [using theorem 2] = λ T +E(Z k−1 1 ) +αλE(X k 1 ) =[using E(X k 1 ) = λ T +E(Z k−1 1 )
]=E(X k 1 )+αλE(X k 1 ) = E(X k 1 )(1 + αλ) =[using IH]=λT (1 + αλ) k (1 + αλ) = λT (1 + αλ) k+1 .
• Conclusion: ∀n ∈ N, E(X n 1 ) = λT (1 + αλ) n .
Theorem 4. Given j ∈ Z + and n ∈ N, if j > n, then E(X n j ) = λT .
Proof. We prove it by Mathematical Induction based on n. Although we have two variables namely j and n, the choice of j is restricted by j > n. So we can cover all the cases for j > n .
• Basis Step: for n = 0 and j > 0, definition 3 and theorem 1 imply X 0 j ∼ P oisson(λT ) ⇒ E(X 0 j ) = λT .
• Induction Step: by theorem 1, we know that for j ≥ 1 and k ∈ N, X k j ∼ P oisson λ(T + Z k−1 j − Z k−1 j−1 ) ⇒ E(X k j ) =[using theorem 2]=λ T + E(Z k−1 j ) − E(Z k−1 j−1 )
.
Assume for n = k, k ≥ 1, j > k = n and k ∈ N, E(X k j ) = λT ——(IH). Now we want to show that for k ≥ 1, j > k + 1 and k ∈ N, E(X k+1 j ) = λT .
Definition 3 and theorem 1 imply X k+1 j ∼ P oisson λ(T +Z k j −Z k j−1 ) = P oisson λ(T + Z k−1 j −Z k−1 j−1 +Z k j −Z k j−1 −Z k−1 j +Z k−1 j−1 ) = P oisson λ(T +Z k−1 j −Z k−1 j−1 +Z k j −Z k−1 j + Z k−1 j−1 − Z k j−1 ) = P oisson
λ (T + Z k−1 j − Z k−1 j−1 ) + (T + Z k j − Z k−1 j ) − (T + Z k j−1 − Z k−1 j−1 )
= P oisson λ(T +Z k−1 j −Z k−1 j−1 )+λ(T +H k j )−λ(T +H k j−1 ) = P oisson λ(T + Z k−1 j − Z k−1 j−1 ) + λ(T + αX k j ) − λ(T + αX k j−1 ) ⇒ E(X k+1 j )=[using theorem 2]=λ(T + E(Z k−1 j ) − E(Z k−1 j−1 )) + λ(T + αE(X k j )) − λ(T + αE(X k j−1 )) =[using E(X k j ) = λ T + E(Z k−1 j ) − E(Z k−1 j−1 )
]=E(X k j ) + λT + αλE(X k j ) − λT − αλE(X k j−1 ) =[firstly, E(X k j ) = λT by IH since j > k + 1 implies j > k, besides, j − 1 > k since j > k + 1. Therefore by using IH, we get E(X k j−1 ) = λT ]=λT + λT + αλλT − λT − αλλT = λT .
• Conclusion: E(X n j ) = λT if j ∈ Z + , n ∈ N and j > n.
Theorem 5. Given j ∈ Z + , n ∈ N, then E(X n j ) = E(X n−1 j ) + λ αE(X n−1 j ) − αE(X n−1 j−1 ) . Proof. Theorem 1 implies X n−1 j ∼ P oisson λ(T + Z n−2 j − Z n−2 j−1 )
⇒ E(X n−1 j ) =[using theorem 2]=λ T + E(Z n−2 j ) − E(Z n−2 j−1 )
.
Theorem 1 also implies X n j ∼ P oisson λ(T + Z n−1 j − Z n−1 j−1 ) = P oisson λ(T + Z n−2 j − Z n−2 j−1 + Z n−1 j − Z n−1 j−1 − Z n−2 j + Z n−2 j−1 ) = P oisson λ(T + Z n−2 j − Z n−2 j−1 ) + λ(Z n−1 j − Z n−2 j ) − λ(Z n−1 j−1 − Z n−2 j−1 ) = P oisson λ(T + Z n−2 j − Z n−2 j−1 ) + λH n−1 j − λH n−1 j−1 = P oisson λ(T + Z n−2 j − Z n−2 j−1 ) + λαX n−1 j − λαX n−1 j−1
⇒ E(X n j ) =[using theorem 2]=λ T + E(Z n−2 j ) − E(Z n−2 j−1 ) + λ αE(X n−1 j ) − αE(X n−1 j−1 )
=[taking E(X n−1 j ) = λ T + E(Z n−2 j ) − E(Z n−2 j−1 ) ]=
E(X n−1 j ) + λ αE(X n−1 j ) − αE(X n−1 j−1 )
.
The expressions of E(X n j ) for j = 1 and j > n are “special", since in these two cases, E(X n j ) can be expressed explicitly by formulas containing λ, α, T and n, while the expression of E(X n j ) for 1 < j ≤ n can only be expressed implicitly by a recursion relationship. Therefore, we decided to distinguish E(X n j ) for three cases in equation (2), namely j = 1, 1 < j ≤ n and j > n , although theorem 5 shows that E(X n j ) = E(X n−1 j ) + λ αE(X n−1 j ) − αE(X n−1 j−1 ) , ∀j ∈ Z + and n ∈ N.
2.3.3 The Expectation of A j n
Recall that A j n :=the time between bus-j’s arriving and bus-(j − 1)’s arriving at stop n, which is the inter-arrival time between bus-j and bus-(j − 1) at stop-n. We assume that E(A j n ) > 0 , since buses will not see each other at the same stop. There are two methods to find E(X n j ) . The first one is similar as what we have done in finding E(X n j ) , i.e. to calculate E(A j i ) with i ∈ {0, 1, 2, 3, 4} and conclude the expression of E(A j n ) from the pattern of the results of E(A j i ) . Since this method is too tedious, we will leave it in section 8.3 in Appendix 2. The second one, which will be used in this section, is to draw the conclusion for E(A j n ) based on equation (2) by using the following corollary.
Corollary 1. E(A j n ) = E(X λ
nj) , ∀j ∈ Z + and n ∈ N.
Proof. Say, at time t 1 , bus-(j − 1) arrives at stop-n and at time t 2 , bus-j arrives at stop-n, so we have A j n = t 2 − t 1 . Passengers who are going to wait for bus-j will come during the time interval [t 1 , t 2 ] due to the gated discipline. The arrival process of passengers is a Poisson Process with rate λ, and this implies X n j ∼ P oisson λ(t 2 − t 1 ) = P oisson(λA j n ) . It follows from theorem 2 that E(X n j ) = λE(A j n ) ⇐⇒ E(A j n ) = E(X
j n