A Faulty Traffic Signal
A 15-second pedestrian signal whose red/green split is itself uniformly random. Closed forms for the probability of red, the expected wait, and the expected total time to cross, each from a one-line integral, with a sample-space picture, an account of length-biasing, and a Monte Carlo check of every result.
Problem
A faulty traffic signal has a 15-second cycle of Red and Green (no Orange). In each cycle, the Red time () is uniformly distributed between 0 to 15 seconds, and the remaining time () is Green. You arrive at a completely random time. If it’s Green, you cross immediately, with your crossing time uniformly distributed over the remaining Green time left. If it’s Red, you wait for Green and then cross, with your crossing time uniformly distributed over the total Green time of that cycle. Find , , , and ?
Throughout, write for the period. Put the red phase at the start of each cycle, on , and the green phase at the end, on ; the answer cannot depend on this choice. Let be the arrival time, uniform on and independent of . Then you meet red exactly when .
The chance of red, and the chance of green
Both random choices, the split and the arrival , are uniform and independent, so the pair is spread evenly over the square . You meet red exactly when , the triangle below the diagonal; you meet green when , the triangle above it. The diagonal cuts the square into two equal halves, so with no calculation at all.
If you prefer the integral, the same answer falls out. For a fixed split , red fills a fraction of the cycle, so . Averaging over the uniform split, whose density is , The split averages out: a single cycle is lopsided, but over many cycles a red second is as likely as a green one, because the average red, , sits exactly in the middle.
A red light means the red was probably long
To average the wait we need the distribution of the split among the cycles where we actually hit red, and that is not the plain uniform split. A long red covers more of the cycle, so it is more likely to be the one you walk into; learning that you met red therefore makes long reds more likely. This effect is known as length-biasing.
We can read the corrected density straight off the cycle. The chance of both meeting red and having a split near is . Dividing by the overall chance of red, , gives the density of the split among red arrivals, It rises with , and it integrates to one. The same reasoning for green gives a density that falls,
How long you wait at a red light
Arrive on red with split . Your arrival is equally likely anywhere in the red, so the red still to come is uniform on , with average . Averaging this over the red-arrival density, With the expected wait is 5 seconds.
The value is larger than a first guess suggests. Averaging the red to and halving it for the uniform wait would give , but this overlooks the length-biasing: longer reds are met more often and carry longer waits, so the average comes to rather than .
How long the crossing takes
If you arrived on red, the whole of the green phase still lies ahead, so your crossing is spread over all of it, , with average . Against the red-arrival density,
If you arrived on green, two quantities are random at once. The green still showing when you arrive is some fraction of the full green, and your crossing then takes some fraction of that. Each fraction is uniform between zero and the whole, so each averages a half, and a half of a half is a quarter: Averaging over the green-arrival density,
So the expected crossing is seconds either way. That the two cases agree is a small coincidence: arriving on red favours short greens, pulling the crossing down, while arriving on green halves the remaining green a second time, and the two pulls happen to cancel.
The total time to cross
The total time is the wait plus the crossing, and the wait is zero unless you arrived on red. Weighing the two cases by their equal probabilities,
With the expected total time to cross is 5 seconds, the same as the red-light wait on its own. There is no hidden reason for the match; the fractions simply add back to .
The same answers, from one diagram
Every mean above can be read straight off a picture, with no integral at all. Redraw the sample square with the arrival time along the bottom and the red duration up the side, so each equally likely scenario is a point spread uniformly over . The line splits it: above the line the red outlasts your arrival and you meet red, below it you meet green.
Two facts do all the work. First, the diagonal cuts the square into two equal triangles, so by inspection. Second, a quantity that varies linearly across the plane has, as its average over any triangle, simply its value at the triangle’s centroid. This holds because the centroid is the mean position of a point dropped uniformly in the triangle, and it sits at the average of the three corners. The red triangle has corners , , , so its centroid lies at ; the green triangle has corners , , , with centroid .
Now read each quantity off at the relevant centroid.
- The wait on red is , the vertical drop from the point down to the diagonal. At the red centroid this is .
- The crossing brings in the one ingredient the square cannot show: you cross over a uniform fraction of the green available, which contributes a clean factor of one half. On red the green available is all of it, , so the crossing averages , worth at the red centroid. On green the green available is the part still showing, , so the crossing averages , worth at the green centroid.
- The total is the wait plus the crossing, weighted by the two equal halves: .
All four required answers, , , and , fall out of two centroids and a single factor of a half. The integrals above were never strictly needed for the means; only the full distribution of the total time, derived next, genuinely calls for calculus.
The shape of the total time
The mean is only a summary; the same rules fix the whole spread of the crossing time, and the simulation at the end traces it out. It is worth deriving, both as a check on that plot and because the answer is tidier than the set-up suggests. Measure time as a fraction of the period: put , where is the total time. Then lives on , and the density of itself is recovered by . Take for the working below. The two arrival types build differently, so we treat them apart and add.
A green arrival. You cross at once, over a uniform fraction of the green still showing. Fix the arrival at : this is a green arrival exactly when the split fell below it, which carries probability , and the crossing is then uniform on with density . A total of size needs , that is , so the green contribution to the density is
A red arrival. Now the total is the wait plus the crossing, . Fix the split at : this is a red arrival with probability , and given it, the wait is uniform on while the crossing is uniform on , the two independent. Their two lengths add to the whole period, so their sum has the trapezoidal density of a convolution, where is the length of overlap, taken as zero when this is negative. Weighting by the red-arrival probability cancels the in the denominator, which is what keeps the answer clean: The overlap is piecewise linear in : it equals for , holds at between the two break points, and equals for . Carrying out the three pieces, the integral collapses to the binary entropy,
Adding the two contributions, This integrates to one, and , which returns the mean found above. The density runs to infinity as , but only as slowly as : most crossings are nearly instant, either a green arrival late in a long green, or a red arrival with little red left. At the other end it falls to zero as , since using almost the whole period needs both a near-full wait and a near-full crossing, which is vanishingly rare. The curve, scaled back to seconds by , is the one drawn over the simulated histogram below.
| Quantity | Closed form | Value at |
|---|---|---|
| s | ||
| s | ||
| s | ||
| s |
Computational verification
We confirm every closed form with a direct simulation. Each trial draws a fresh split and a fresh arrival , classifies the arrival, and times the wait and the crossing by the rules above. With fifty million trials the Monte Carlo estimates agree with the exact values to three decimal places.
import numpy as np
rng = np.random.default_rng(20260529)
N, T = 50_000_000, 15.0
R = rng.uniform(0, T, N) # red duration ~ U(0,T); green = T-R
A = rng.uniform(0, T, N) # arrival uniform within the cycle
is_red = A < R
# probabilities
print(is_red.mean(), (~is_red).mean()) # -> 0.5, 0.5
# waiting time: red -> remaining red R-A; green -> 0
wait = np.where(is_red, R - A, 0.0)
print(wait[is_red].mean()) # E[W | red] -> T/3 = 5.0
# crossing time: red over full green (T-R); green over remaining green (T-A)
u = rng.uniform(0, 1, N)
cross = np.where(is_red, u * (T - R), u * (T - A))
print(cross[is_red].mean(), cross[~is_red].mean()) # both -> T/6 = 2.5
print((wait + cross).mean()) # E[total] -> T/3 = 5.0
| Quantity | Exact | Monte Carlo |
|---|---|---|