0% found this document useful (0 votes)
33 views16 pages

How Long Might We Wait at Random

The document discusses the distribution of maximum line length for customers waiting at random for one of three servers. It presents a Julia program that simulates this queue and analyzes the asymptotic distribution of the maximum length. Closed-form expressions are unwieldy, so a numeric approach is taken. Poisson clumping and stationary distributions are used to predict the maximum length for large numbers of customers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views16 pages

How Long Might We Wait at Random

The document discusses the distribution of maximum line length for customers waiting at random for one of three servers. It presents a Julia program that simulates this queue and analyzes the asymptotic distribution of the maximum length. Closed-form expressions are unwieldy, so a numeric approach is taken. Poisson clumping and stationary distributions are used to predict the maximum length for large numbers of customers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

How Long Might We Wait at Random?

Steven Finch
arXiv:1906.07021v3 [math.HO] 27 Aug 2022

August 27, 2022


Abstract. In discrete time, customers arrive at random. Each waits
until one of three servers is available; each thereafter departs at random. We
seek the distribution of maximum line length of idle customers. Algebraic ex-
pressions obtained for the two-server scenario do not appear feasible here. We
also review well-known distributional results for maximum wait time associated
with an M/M/1 queue and speculate about their generalization.
In queueing theory, maximum line length and maximum wait time are different
sides of the same coin, one spatial (Section 1) and the other temporal (Section 2).
1. In Spatium
Let 0 < r < 1 and 0 < p < 3r. Consider the Julia program:
u = 0
m = 0
for t=1:n
x = rand()<p # x=1 means that an arrival occurs
y1 = rand()<r # y1+y2+y3=3 means that three departures occur
y2 = rand()<r
y3 = rand()<r
if u==0
u = x # increment is 1 or 0
else
if u==1
u = max(0,u+x-y1) # increment is 1, 0 or -1
elseif u==2
u = max(0,u+x-y1-y2) # increment is 1, 0, -1 or -2
else
u = max(0,u+x-y1-y2-y3) # increment is 1, 0, -1, -2 or -3
end
end
m = max(m,u)
end
return m
0
Copyright © 2019 & 2022 by Steven R. Finch. All rights reserved.

1
How Long Might We Wait at Random? 2

which simulates the maximum value of a Geo/Geo/3 queue with LAS-DA over n time
steps. The Boolean expressions containing Julia’s Uniform [0, 1] random deviate gen-
erator ensure that X ∼ Bernoulli(p) and Y ∼ Bernoulli(r). The word “Geometric”
arises because

P {time lapse between adjacent arrivals is i} = p q i−1 , i≥1

where q = 1 − p and

P {time lapse between adjacent departures is j} = r sj−1 , j≥1

where s = 1 − r. Clearly 3s − 2 < q < 1. LAS stands for “late arrival system”
and DA stands for “delayed access” [1]; in particular, a customer entering an empty
queue at time t is not immediately eligible for service, but rather at time t + 1. We
study the asymptotic distribution of the maximum Mn . This section is best thought
of as an extended addendum to [2], written for the sake of completeness. The only
difference with our earlier work is that closed-form expressions here become unwieldy
and thus our approach is more numeric and less symbolic.
The Poisson clumping heuristic [3], while not a theorem, gives results identical
to exact asymptotic expressions when such exist, and evidently provides excellent
predictions otherwise. Consider an irreducible positive recurrent Markov chain with
stationary distribution π. For large enough k, the maximum of the chain satisfies
 
πk
P {Mn < k} ∼ exp − n
E(C)
as n → ∞, where C is the sojourn time in k during a clump of nearby visits to k.
Starting with transition matrix
 
q p 0 0 0 0 0 ···
 qr pr + qs ps 0 0 0 0 ··· 
2 2 2 2
 
 qr pr + 2qrs 2prs + qs ps 0 0 0 ··· 
qr 3 pr 3 + 3qr 2 s 3pr 2 s + 3qrs2 3prs2 + qs3 ps3 0 0 ···
 
 
0 qr 3 pr 3 + 3qr 2 s 3pr 2 s + 3qrs2 3prs2 + qs3 ps3 0 ···
 
 
 0 0 qr 3 3 2 2
pr + 3qr s 3pr s + 3qrs 2 2
3prs + qs 3 ps3 ···

 
 0 0 0 qr 3 pr + 3qr s 3pr s + 3qrs 3prs2 + qs3
3 2 2 2 ··· 
 
.. .. .. .. .. .. .. ..
. . . . . . . .

we obtain [4]
πj = πj∗ π3 for 0 ≤ j ≤ 2,
 −1
1 ∗ ∗ ∗
π3 = + π0 + π1 + π2 ,
1−ω
How Long Might We Wait at Random? 3

πj = ω j−3π3 for j≥4


where
1  2 3
 2 2
 3 2
 2 3
 3
π2∗ = 1 − 3prs − qs − 3pr s + 3qrs ω − pr + 3qr s ω − qr ω ,
ps2
1 
1 − 2prs − qs2 π2∗ − 3pr 2s + 3qrs2 − pr 3 + 3qr 2 s ω − qr 3 ω 2 ,
    
π1∗ =
ps
1
π0∗ = (1 − pr − qs) π1∗ − pr 2 + 2qrs π2∗ − pr 3 + 3qr 2 s − qr 3 ω
   
p
and 0 < ω < 1 satisfies the cubic equation ω = (qω + p)(rω + s)3 , that is,
"  1/3  1/3 #
1 2 χ+θ
ω= (−3 + 2r + 3ps) + (3q − r)r −
3qr χ+θ 2

where p
χ = −9qr 2 + 2r 3 − 27q 2 s, θ= 4(3q − r)3 r 3 + χ2 .
Note that, if k = log1/ω (n) + h + 1, we have
 k  h+1
1 1
=n
ω ω
thus
πk n = π3 ω k−3n = π3 ω h−2 .
We need now to calculate E(C). Consider a random walk on the integers consisting
of incremental steps satisfying


 −3 with probability qr 3 ,
 −2 with probability pr 3 + 3qr 2s,


−1 with probability 3pr 2 s + 3qrs2 ,
0 with probability 3prs2 + qs3 ,




1 with probability ps3 .

For nonzero j, let νj denote the probability that, starting from −j, the walker eventu-
ally hits 0. Let ν0 denote the probability that, starting from 0, the walker eventually
returns to 0 (at some future time). We have two values for ν0 : when it is used in a
recursion, it is equal to 1; when it corresponds to a return probability, it retains the
symbol ν0 . Let j ≥ 1. Using

νj = ps3 νj−1 + (3prs2 + qs3 )νj + (3pr 2 s + 3qrs2 )νj+1 + (pr 3 + 3qr 2 s)νj+2 + qr 3 νj+3,
How Long Might We Wait at Random? 4

ν0 = ps3 ν−1 + (3prs2 + qs3 ) + (3pr 2s + 3qrs2)ν1 + (pr 3 + 3qr 2 s)ν2 + qr 3 ν3


define

X
F (z) = νj z j
j=1
∞ ∞ ∞
3
X
j−1 2 3
X
j 3pr 2 s + 3qrs2 X
= ps z νj−1 z + (3prs + qs ) νj z + νj+1 z j+1
j=1 j=1
z j=1
∞ ∞
pr 3 + 3qr 2 s X j+2 qr 3 X
+ νj+2z + 3 νj+3 z j+3
z2 j=1
z j=1

3pr 2 s + 3qrs2
= ps3 z [F (z) + 1] + (3prs2 + qs3 )F (z) + [F (z) − ν1 z]
z
pr 3 + 3qr 2 s  2
 qr 3  2 3

+ F (z) − ν1 z − ν2 z + F (z) − ν1 z − ν2 z − ν3 z
z2 z3
equivalently
3pr 2 s + 3qrs2 pr 3 + 3qr 2 s qr 3
 
3 2 3
1 − ps z − 3prs − qs − − − 3 F (z)
z z2 z
2 2 3 2
3pr s + 3qrs pr + 3qr s qr 3
= ps3 z − (ν1 z) − (ν1 z + ν2 z 2
) − (ν1 z + ν2 z 2 + ν3 z 3 )
z z2 z3
equivalently
 3
qr + (pr 3 + 3qr 2s)z + (3pr 2 s + 3qrs2 )z 2 − (1 − 3prs2 − qs3 )z 3 + ps3 z 4 F (z)


= −ps3 z 4 + (3pr 2 s + 3qrs2)z 2 (ν1 z) + (pr 3 + 3qr 2 s)z(ν1 z + ν2 z 2 ) + qr 3 (ν1 z + ν2 z 2 + ν3 z 3 )

equivalently

(1 − z) qr 3 + (3q − 2r + 3pr)r 2z + (1 + s + s2 − 3ps2 )rz 2 − ps3 z 3 F (z)


 

= −ps3 z 4 + 3pr 2 sz 3 ν1 + 3qrs2z 3 ν1 + pr 3 z 2 ν1 + pr 3 z 3 ν2 + 3qr 2 sz 2 ν1 + 3qr 2 sz 3 ν2 + qr 3 zv1


+ qr 3 z 2 ν2 + z 3 ν0 − ps3 ν−1 − (3prs2 + qs3 ) − (3pr 2s + 3qrs2)ν1 − (pr 3 + 3qr 2s)ν2
 

= z 3 ν0 + (qr + prz + 3qsz) r 2 zν1 + qr 3 z 2 ν2 − ps3 z 3 ν−1 − 3prs2z 3 − qs3 z 3 − ps3 z 4 .

Examine the denominator of F (z). Only the first three of its four zeroes z1 , z2 , 1,
z3 are of interest (the fourth is > 1). Substituting z = 1, z = z1 and z = z2 into the
numerator NF of F (z), then setting NF = 0, gives three equations in four unknowns.
Let j ≥ 1. Using

ν−j = ps3 ν−j−1 +(3prs2 +qs3 )ν−j +(3pr 2 s+3qrs2 )ν−j+1 +(pr 3 +3qr 2 s)ν−j+2 +qr 3 ν−j+3 ,
How Long Might We Wait at Random? 5

ν0 = ps3 ν−1 + (3prs2 + qs3 ) + (3pr 2s + 3qrs2)ν1 + (pr 3 + 3qr 2 s)ν2 + qr 3 ν3


define

X
G(z) = ν−j z j
j=1
∞ ∞ ∞
ps3 X j+1
X X
= ν−j−1 z + (3prs + qs ) ν−j z + (3pr s + 3qrs )z ν−j+1 z j−1
2 3 j 2 2
z j=1 j=1 j=1

X ∞
X
3 2 2 j−2 3 3
+ (pr + 3qr s)z ν−j+2z + qr z ν−j+3 z j−3
j=1 j=1
3
ps
= [G(z) − ν−1 z] + (3prs2 + qs3 )G(z) + (3pr 2 s + 3qrs2 )z [G(z) + 1]
z h ν1 i h ν1 ν2 i
+ (pr 3 + 3qr 2 s)z 2 G(z) + 1 + + qr 3 z 3 G(z) + 1 + + 2
z z z
equivalently

ps3
 
2 3 2 2 3 2 2 3 3
1− − 3prs − qs − (3pr s + 3qrs )z − (pr + 3qr s)z − qr z G(z)
z
ps3  ν1   ν1 ν2 
=− (ν−1 z) + (3pr 2s + 3qrs2)z + (pr 3 + 3qr 2 s)z 2 1 + + qr 3 z 3 1 + + 2
z z z z
equivalently
 3 4
qr z + (pr 3 + 3qr 2s)z 3 + (3pr 2s + 3qrs2 )z 2 − (1 − 3prs2 − qs3 )z + ps3 G(z)


= ps3 (ν−1 z) − (3pr 2s + 3qrs2 )z 2 − (pr 3 + 3qr 2 s)z 2 (z + ν1 ) − qr 3 z 2 z 2 + ν1 z + ν2




equivalently

(1 − z) ps3 − (1 + s + s2 − 3ps2 )rz − (3q − 2r + 3pr)r 2 z 2 − qr 3 z 3 G(z)


 

= ps3 zν−1 − (3prs + 3qs2 + pr 2 z + 3qrsz + qr 2 z 2 )rz 2 − (pr + 3qs + qrz)r 2 z 2 ν1 − qr 3 z 2 ν2 .

Examine the denominator of G(z). Only the zero z4 of smallest modulus interests
us. Substituting z = z4 into the numerator NG of G(z), and setting NG = 0, gives a
fourth equation (to include with the other three from earlier). For example, if

p = 31 , q = 23 , r = 61 , s= 5
6

we have
ω = 0.5744080010..., π3 = 0.1777380492...
How Long Might We Wait at Random? 6

from earlier and


ν0 = 0.8437587438..., ν−1 = 0.9309681530...,
ν1 = 0.5744080010..., ν2 = 0.3299445517...

after solving the simultaneous system in ν0 , ν−1 , ν1 , ν2 . Observe that


 
P Mn ≤ log1/ω (n) + h = P Mn < log1/ω (n) + h + 1
 
π3 (1 − ν0 ) h
∼ exp − ω
ω2

as n → ∞. The ratio within the exponential argument is

π3 (1 − ν0 )
= 0.0841657058...
ω2
and hence
 
π3 (1−ν0 )
ln(n) γ + ln ω2 1
E (Mn ) ≈ + +
ln( ω1 ) ln( ω1 ) 2
≈ (1.8037019224...) ln(n) − (2.9229790566...)

for sufficiently large n, where γ denotes Euler’s constant [5]. Such moment formulas
usually contain tiny periodic fluctuations, but we omit these from consideration.
The use of an expected maximum for performance analysis, instead of a simple
average, does not appear to lead to surprising outcomes. A corollary of the preceding
numerical results is that, in a busy hospital emergency room (with p = 1/3), one fast
doctor (with r = 1/2) outperforms three slow doctors (each with r = 1/6). For
average queue lengths [4],

X pq
jπj = = 1.33333...
j=1
r−p

corresponding to Geo/Geo/1 and



X 3 − 2ω
jπj = π1 + 2π2 + π3 = 2.56365...
j=1
(1 − ω)2

corresponding to Geo/Geo/3. This is also consistent with results in [6] governing


deterministic traffic signals: we do better with an RGRGRG... pattern than with
RRRGGG....
How Long Might We Wait at Random? 7

2. In Tempore
Let c ≥ 1 be an integer and 0 < λ < cµ. Consider the R program:
K <- rpois(1,n*lambda)
P <- matrix(0,K,3) # matrix of patients
P[,1] <- sort(runif(K,0,n)) # arrival times
P[,3] <- rexp(K,mu) # treatment lengths
D <- rep(0,c) # vector of doctors
k.sys <- function(i,P) P[i,2]+P[i,3]-P[i,1]
k.que <- function(i,P) P[i,2]-P[i,1]
for (i in 1:K)
{
j <- which.min(D)
P[i,2] <- max(P[i,1],D[j])
D[j] <- P[i,2] + P[i,3] # departure times
}
W.sys <- sapply(1:K,k.sys,P=P)
W.que <- sapply(1:K,k.que,P=P)
list(max(W.sys),max(W.que))
which simulates the maximum wait time associated with an M/M/c queue over the
time interval [0, n]. More precisely, at any arrival time t = Pi,1 , let Wsys denote the
ith patient wait time in the system (either queue or treatment) and Wque denote the
ith patient wait time in the queue (excluding treatment). For c = 1, the maximums
of Wsys and Wque over all arrival times up to n satisfy [7, 8, 9]
 
2
 
lim P (µ − λ) max Wsys ≤ ln λ(1 − ρ) n + x = exp(− exp(−x)),
n→∞ 0≤t≤n
 
2
 
lim P (µ − λ) max Wque ≤ ln λ(1 − ρ) ρ n + x = exp(− exp(−x))
n→∞ 0≤t≤n

where ρ = λ/µ. These imply


 
P max Wsys ≤ y ≈ exp −λ(1 − ρ)2 n exp [−(µ − λ)] y ,
 
0≤t≤n
 
≈ exp −λ(1 − ρ)2 ρ n exp [−(µ − λ)] y
 
P max Wque ≤ y
0≤t≤n

for large enough n. Also, if λ = 1/3 and µ = 1/2, then


γ + ln [λ(1 − ρ)2 ]
 
ln(n)
E max Wsys = + = 6 ln(n) − 16.31172...,
0≤t≤n µ−λ µ−λ
How Long Might We Wait at Random? 8

γ + ln [λ(1 − ρ)2 ρ]
 
ln(n)
E max Wque = + = 6 ln(n) − 18.74451....
0≤t≤n µ−λ µ−λ
In particular, assuming n = 20000, the expected maximum wait times are 43.109 and
40.676 respectively.
For c ≥ 2, no analogous formulas are known. Assuming n = 20000, λ = 1/3 and
µ = 1/(2c), we estimate via simulation that
   
E max Wsys ≈ 51.0 > 43.109, E max Wque ≈ 39.4 < 40.676
0≤t≤n 0≤t≤n

for c = 2 and
   
E max Wsys ≈ 64.1 > 51.0, E max Wque ≈ 38.3 < 39.4
0≤t≤n 0≤t≤n

for c = 3. With regard to the expected maximum of Wsys , one fast doctor outperforms
c slow doctors. With regard to the expected maximum of Wque , however, c slow
doctors outperform one fast doctor. Experimental histograms of such maximums
appear to be roughly Gumbel-shaped: a two-moment fit provides a fairly compelling
but ultimately inconclusive match between theory and data. Only rigorous analysis
for c ≥ 2 will clarify the situation.
The same Wque trend occurs for simple averages. Given λ = 1/3, µ = 1/(2c) as
before and allowing n → ∞, we have the following when c = 1:
1 λ
E (Wque ) = E (Wsys ) − = = 4,
µ (µ − λ) µ
when c = 2:
1 λ2
E (Wque ) = E (Wsys ) − = = 3.2
µ (2µ − λ) (2µ + λ) µ
and when c = 3:
1 λ3
E (Wque ) = E (Wsys ) − = = 2.66666....
µ (3µ − λ) (λ2 + 4λµ + 6µ2 ) µ
Such mean results apply not only to the FIFO discipline (first in, first out), but also
to the LIFO (last in, first out) and SIRO (serve in random order) disciplines. The
underlying SIRO wait time distribution is more complicated than that for FIFO, as
shown for c = 1 in [10, 11].
Alternative treatments of M/M/1 maximum wait times include [12, 13], where
n or k refer not to the length of the time interval but instead the total number
of customers. Simple averages of wait times for Geo/Geo/c can be calculated by
methods given in [14]; maximums remain open.
How Long Might We Wait at Random? 9

Figure 1: Maximum line length over n time steps, with 1 server

3. Acknowledgements
I am thankful to Guy Louchard for introducing me to the Poisson clumping heuristic
(especially recursions for νj and ν−j ), and to Stephan Wagner for extracting discrete
Gumbel asymptotics in [15] (a contribution leading to [2, 16, 17]). See also [18, 19]
for work involving the case of Uniform[a, b] service times and Deterministic[a] subcase
(b → a). The creators of R, Julia, Mathematica and Matlab, as well as administrators
of the MIT Engaging Cluster and the MIT Supercloud Cluster, earn my gratitude
every day.
How Long Might We Wait at Random? 10

Figure 2: Maximum line length over n time steps, with 2 servers


How Long Might We Wait at Random? 11

Figure 3: Maximum line length over n time steps, with 3 servers


How Long Might We Wait at Random? 12

Figure 4: Maximum of Wsys over time interval of length n, with 1 server

Figure 5: Maximum of Wque over time interval of length n, with 1 server


How Long Might We Wait at Random? 13

Figure 6: Maximum of Wsys over time interval of length n, with 2 servers

Figure 7: Maximum of Wque over time interval of length n, with 2 servers


How Long Might We Wait at Random? 14

Figure 8: Maximum of Wsys over time interval of length n, with 3 servers

Figure 9: Maximum of Wque over time interval of length n, with 3 servers


How Long Might We Wait at Random? 15

References
[1] J. J. Hunter, Mathematical Techniques of Applied Probability. Vol. 2: Discrete
Time Models: Techniques and Applications, Academic Press, 1983, pp. 189–200;
MR0719019.

[2] S. Finch, Geo/Geo/2 queues and the Poisson clumping heuristic,


arXiv:1902.09272.

[3] D. Aldous, Probability Approximations via the Poisson Clumping Heuristic,


Springer-Verlag, 1989, pp. 1–8, 23–25, 30; MR0969362.

[4] J. R. Artalejo and O. Hernández-Lerma, Performance analysis and optimal con-


trol of the Geo/Geo/c queue, Performance Evaluation 52 (2003) 15–39.

[5] S. R. Finch, Euler-Mascheroni constant, Mathematical Constants, Cambridge


Univ. Press, 2003, pp. 28–40; MR2003519.

[6] S. Finch and G. Louchard, Conjectures about traffic light queues,


arXiv:1810.03906.

[7] D. L. Iglehart, Extreme values in the GI/G/1 queue, Annals Math. Statist. 43
(1972) 627–635; MR0305498

[8] D. L. Iglehart, Regenerative Simulation for Extreme Values, Stanford Univ. Tech-
nical Report 43 (1977); http://apps.dtic.mil/docs/citations/ADA047945.

[9] A. W. Berger and W. Whitt, Maximum values in queueing processes, Probab.


Engrg. Inform. Sci. 9 (1995) 375–409; MR1365267.

[10] L. Flatto, The waiting time distribution for the random order service M/M/1
queue, Annals Appl. Probab. 7 (1997) 382–409; MR1442319

[11] A. V. Lebedev, Maxima of waiting times for the random order service M|M|1
queue (in Russian); Problemy Peredachi Informatsii v. 41 (2005) n. 3, 123–127;
Engl. transl. in Problems of Information Transmission v. 41 (2005) n. 3, 296–299;
MR2163855.

[12] M. I. Gomes, On maxima of waiting times, Portugal. Math. 39 (1980) 331–339


(1985); MR0776245.

[13] Y. H. Abdelkader and M. Al-Wohaibi, Computing the performance measures in


queueing models via the method of order statistics, J. Appl. Math. 2011, art.
790253; MR2854962.
How Long Might We Wait at Random? 16

[14] A. S. Alfa, Applied Discrete-Time Queues, 2nd ed., Springer-Verlag, 2016, pp.
143–150, 227–236; MR3468938.

[15] S. Finch, The maximum of an asymmetric simple random walk with reflection,
arXiv:1808.01830.

[16] S. Finch and G. Louchard, Traffic light queues and the Poisson clumping heuris-
tic, arXiv:1810.12058.

[17] S. Finch, M/M/c queues and the Poisson clumping heuristic, arXiv:1904.04054.

[18] S. Finch, M/G/1-FIFO queue with uniform service times, arXiv:2206.11108.

[19] S. Finch, M/D/1 queues with LIFO and SIRO policies, arXiv:2208.09980.
Steven Finch
MIT Sloan School of Management
Cambridge, MA, USA
steven finch@harvard.edu

You might also like