To get from our house to the usually-empty car park my kids like to practice their bike-riding in, we have to cross at least one road.

Traffic flows one way along Cromwell Road (northbound), and at the junction, either carries on or turns right into Highland Road (which is also a one-way street, heading east); our options are to make a single crossing (over Cromwell Road before the junction, where it is busier) or two crossings (over Highland Road and Cromwell Road, in the quieter stretches). The question is, which option can we expect to be quicker?

My intuition doesn’t have a good answer for this: I would not be surprised to find that either - or neither - option was the better one.

### A model

Let’s model the traffic heading into Highland Road using a Poisson distribution with a mean of $\lambda_H$: $T_H \sim \Po(\lambda_H)$. Similarly, let the Cromwell Road traffic follow $T_C \sim \Po(\lambda_C)$.

The traffic on the busy bit of Cromwell Road also follows a Poisson distribution, with mean $\lambda_H + \lambda_C$.

And to cross the road, we need to have a gap between traffic events of at least $g$ seconds. So how long would we expect to wait for one of those?

### Another distribution

The time between events in a Poisson distribution is given by the exponential distribution, which has a pdf of $f(x) = \lambda e^{-\lambda x}$ and a cdf of $F(x) = 1 - e^{-\lambda x}$.

So, how does it go down if we’re waiting for a chance to cross? The probability of immediately having a chance to cross is $1-F(g)$, or $e^{-\lambda g}$. If we don’t get to cross, we need to wait some random time drawn from the distribution, then try again.

There are two parts to that: how many times will we need to wait, and how long will we wait if we do?

### How many times?

Nicely, this is (very closely related to) a geometric distribution: the number of gaps we see is $G \sim \Geo(e^{-\lambda g})$, which has an expected value of $e^{\lambda g}$.

The number of times we need to wait is therefore $e^{\lambda g} - 1$, because if nothing is coming when we first get there, we cross straight away.

### How long must we wait?

If something is coming, we need to wait a bit - but less than time $g$, or else we’d have been able to cross, so we need to work out the expected value of the exponential distribution, given that $x < g$.

That’s tedious: the expected value is $\frac{\int_0^g x\lambda e^{-\lambda x} \dx}{\int_0^g \lambda e^{-\lambda x} \dx}$, which works out to be…

$\frac{1}{\lambda} - \frac{g}{e^{\lambda g} - 1}$

That means, on average, we need to wait a total of $\left( e^{\lambda g} - 1 \right)\left(\frac{1}{\lambda} - \frac{g}{e^{\lambda g} - 1}\right)$ to cross any given road.

That simplifies a little to $\frac{e^{\lambda g} - 1}{\lambda} - g$.

Crossing the busy bit of Cromwell Road takes $E_b = \frac{e^{(\lambda_H + \lambda c)g}}{\lambda_H + \lambda_C} - g$.

Crossing the quiet bits of both roads lakes $E_q = \frac{e^{\lambda_H}}{\lambda_H} + \frac{e^{\lambda_C}}{\lambda_C} - 2g$.

And it’s still not clear – even after a few pages of algebra – which is better! Desmos suggests that there is a critical point (if $g < g_0$, you’re better to cross the busy road, otherwise cross two quiet ones), but it’s not obvious how they’re related. In fact, there’s a slightly nasty dependence on $g$ and $e^g$ which makes it impossible to solve exactly.

### Whoosh

Ah, sensei, I’ve been expec… let’s not go down that route, shall we?

“We haven’t said anything about units. Let’s measure things in crossing-times and let $g=1$, without loss of generality.”

OK.

“The average gap between cars is much longer than it takes to cross the road, so $\lambda < 1$ in both cases.”

Right.

“So we’re comparing $E_b = e^{\lambda_H + \lambda_C}{\lambda_C + \lambda_H} - 1$ with $E_q = \frac{e^\lambda_H}{\lambda_H} + \frac{e^{\lambda_C}}{C} - 2$.”

Is that nicer?

“Of course it is. $\frac{e^k}{k} -1 \approx \frac{1}{k} + O(k^2)$.”

How did I not see that?

“So the $E_b \approx \frac{1}{\lambda_C + \lambda H}$, and $E_q \approx \frac{1}{\lambda_C} + \frac{1}{\lambda_H}$.”

And which of those is bigger?

“$\frac{1}{x} + \frac{1}{y} > \frac{1}{x+y}$ for all positive $x$ and $y$, so $E_Q > E_B$ and you should cross the busy street.”

Thank you, sensei.

“Don’t forget to look both ways. There are all sorts of threats out there.”

I’m not sure I like the look in your eyes there, sensei.

Did you approach it a different way? I’d love to hear about it if you did!