4 min read

Can You Get A Haircut Already?

Table of Contents

Problem

At your local barbershop, there are always four barbers working simultaneously. Each haircut takes exactly 15 minutes, and there’s almost always one or more customers waiting their turn on a first-come, first-served basis.

Being a regular, you prefer to get your hair cut by the owner, Tiffany. If one of the other three chairs opens up, and it’s your turn, you’ll say, β€œNo thanks, I’m waiting for Tiffany.” The person behind you in line will then be offered the open chair, and you’ll remain at the front of the line until Tiffany is available.

Unfortunately, you’re not alone in requesting Tiffany β€” a quarter of the other customers will hold out for Tiffany, while no one will hold out for any of the other barbers.

One Friday morning, you arrive at the barber shop to see that all four barbers are cutting hair, and there is one customer waiting. You have no idea how far along any of the barbers is in their haircuts, and you don’t know whether or not the customer in line will hold out for Tiffany.

What is the expected wait time for getting a haircut from Tiffany?

Solution

Let TT be the random variable of the remaining time for haircut being done by Tiffany.

Let BiB_i be the random variable of the remaining time for haircut being done by Barber ii, for i=1,2,3i=1,2,3.

Let CTC_T be the indicator random variable which takes the value 11 if the waiting customer holds out for Tiffany and 00 otherwise.

We have,

T∼U(0,15)Bi∼U(0,15),i=1,2,3P[CT=1]=14,P[CT=0]=34\begin{aligned} T &\sim& \mathcal{U}(0,15) \\ B_i &\sim& \mathcal{U}(0,15), i = 1,2,3 \\ \mathbb{P}[C_T = 1] = \frac{1}{4} &,& \mathbb{P}[C_T = 0] = \frac{3}{4} \end{aligned}

Let YY be the random variable of the waiting time for Tiffany when there is one customer waiting.

We have,

Y={15+TCT=115+TCT=0,T<min⁑(B1,B2,B3)TCT=0,Tβ‰₯min⁑(B1,B2,B3)\begin{aligned} Y = \begin{cases} 15 + T & C_T = 1 \\ 15 + T & C_T = 0, T < \min(B_1, B_2, B_3) \\ T & C_T = 0, T \geq \min(B_1, B_2, B_3) \end{cases} \end{aligned}

The expected wait time for getting a haircut from Tiffany, E[Y]\mathbb{E}[Y] is given by

P[CT=1]β‹…E[Y∣CT=1]+P[CT=0]β‹…E[Y∣CT=0]=14(15+E[T])+34E[Y∣CT=0]\begin{aligned} \mathbb{P}[C_T = 1]\cdot\mathbb{E}[Y | C_T = 1] + \\ \mathbb{P}[C_T = 0]\cdot\mathbb{E}[Y | C_T = 0] \\ = \frac{1}{4}(15 + \mathbb{E}[T]) + \frac{3}{4} \mathbb{E}[Y | C_T=0] \end{aligned}

As T∼U(0,15)T \sim \mathcal{U}(0,15),

E[T]=0+152=7.5\begin{aligned} \mathbb{E}[T] = \frac{0 + 15}{2} = 7.5 \end{aligned}

To calculate E[Y∣CT=0]\mathbb{E}[Y \vert C_T=0], we need the distribution function of B=min⁑(B1,B2,B3)B=\min(B_1, B_2,B_3).

By definition,

FB(x)=P[B≀x]=1βˆ’P[B>x]=1βˆ’P[min⁑(B1,B2,B3)>x]\begin{aligned} F_B(x)=\mathbb{P}[B \leq x] = 1 - \mathbb{P}[B>x] \\ = 1 - \mathbb{P}[\min(B_1,B_2,B_3) > x] \end{aligned}

From the above we get,

E[Y∣T,CT=0]=(15+T)(1βˆ’FB(T))+Tβ‹…FB(T)=15(1βˆ’FB(T))+T\begin{aligned} \mathbb{E}[Y | T, C_T=0] = (15+T)(1-F_B(T)) + \\ T \cdot F_B(T) \\ = 15(1-F_B(T)) + T \end{aligned}

Using Symmetry

An elegant way of calculating E[Y∣CT=0]\mathbb{E}[Y \vert C_T=0] from \ref{cond_exp_y_t} without deriving FBF_B explicitly is as follows,

E[Y∣CT=0]=E[E[Y∣T,CT=0]]=E[15(1βˆ’FB(T))]+E[T]=15β‹…14+7.5=11.25\begin{aligned} \mathbb{E}[Y \vert C_T=0] = \mathbb{E}[\mathbb{E}[Y \vert T, C_T=0]] \\ = \mathbb{E}[15(1-F_B(T))] + \mathbb{E}[T] \\ = 15\cdot \frac{1}{4} + 7.5 = 11.25 \end{aligned}

The quantity E[1βˆ’FB(T)]\mathbb{E}[1-F_B(T)] can be interpreted as the average probability of TT being the minimum of T,B1,B2T, B_1, B_2 and B3B_3, which by symmetry is 14\frac{1}{4}.

Derivation of FBF_B

To derive FBF_B we need to first calculate P[min⁑(B1,B2,B3)>x]\mathbb{P}[\min(B_1,B_2,B_3) > x].

Of course, min(B1,B2,B3)>xmin(B_1,B_2,B_3)>x exactly when Bi>xB_i>x for i=1,2i=1,2 and 33.

Since these variables are i.i.d., we have

P[min⁑(B1,B2,B3)>x]=P[B1>x]β‹…P[B2>x]β‹…P[B3>x]=P(B1>x)3\begin{aligned} \mathbb{P}[\min(B_1,B_2,B_3) > x] &= \mathbb{P}[B_1>x] \cdot \mathbb{P}[B_2>x] \cdot \mathbb{P}[B_3>x] \\ &= \mathbb{P}(B_1>x)^3 \end{aligned}

As the BiB_i are uniformly distributed on (0,15)(0,15), this yields

FB(x)={1βˆ’(15βˆ’x15)3x∈(0,15)0x<01y>15}.\begin{aligned} F_B(x) = \left\{ \begin{array}{ll} 1 - \left(\frac{15-x}{15}\right)^3 & x \in (0, 15)\\ 0 & x < 0\\ 1 & y > 15 \end{array} \right\}. \end{aligned}

From \ref{min_uniform_iid} and \ref{cond_exp_y_t} we get,

E[Y∣T,CT=0]=15(15βˆ’T15)3+T\begin{aligned} \mathbb{E}[Y | T, C_T=0] = 15\left( \frac{15-T}{15} \right) ^3 + T \end{aligned}

From the above we get,

E[Y∣CT=0]=∫015fT(t)(15(15βˆ’t15)3+t)dt=∫015115(15(15βˆ’t15)3+t)dt=11.25\begin{aligned} \mathbb{E}[Y | C_T=0] = \int_0^{15} f_T(t) \left(15\left( \frac{15-t}{15} \right) ^3 + t\right) dt \\ = \int_0^{15} \frac{1}{15} \left(15\left( \frac{15-t}{15} \right) ^3 + t \right ) dt \\ = 11.25 \end{aligned}

where fT(t)=115f_T(t) = \frac{1}{15} is the density function of TT.

Calculating E[Y]\mathbb{E}[Y]

From the above we get,

E[Y]=14(15+E[T])+34E[Y∣CT=0]=14β‹…22.5+34β‹…11.25=14.0625\begin{aligned} \mathbb{E}[Y] = \frac{1}{4}(15+\mathbb{E}[T]) + \frac{3}{4} \mathbb{E}[Y | C_T=0] \\ = \frac{1}{4} \cdot 22.5 + \frac{3}{4} \cdot 11.25 = 14.0625 \end{aligned}

Therefore the expected wait time for getting a haircut from Tiffany is 14.0625 mins.

Monte Carlo Simulation

from random import random, uniform

runs = 1000000
total_wait_time = 0
for _ in range(runs):
    t, b1, b2, b3 = [uniform(0, 15) for _ in range(4)]
    if random() <= 0.25:
        wait_time = 15 + t
    else:
        if t < min(b1, b2, b3):
            wait_time = 15 + t
        else:
            wait_time = t
    total_wait_time += wait_time
print("Average wait time: ", total_wait_time/runs)