Last month, when I traveled to Hong Kong, I stayed at a guesthouse in a place called the Chungking Mansions. Located in Tsim Sha Tsui, it’s one of the most crowded, sketchiest, and cheapest places to stay in Hong Kong.
Chungking Mansions in Tsim Sha Tsui
Of the 17 floors, the first few are teeming with Indian and African restaurants and various questionable businesses. The rest of the floors are guesthouses and private residences. One thing that’s unusual about the building is the structure of its elevators.
The building is partitioned into five disjoint blocks, and each block has two elevators. One of the elevators only goes to the odd numbered floors, and the other elevator only goes to the even numbered floors. Neither elevator goes to the second floor because there are stairs.
Elevator Schematic of Chungking Mansions
I lived on the 14th floor, and man, those elevators were slow! Because of the crazy population density of the building, the elevator would stop on several floors on the way up and down. Even more, people often carried furniture on the elevators, which took a long time to load and unload.
To pass the time, I timed exactly how long it took between arriving at the elevator on the ground floor, waiting for the elevator to come, riding the elevator up, and getting off at the 14th floor. After several trials, the average time came out to be about 4 minutes. Clearly, 4 minutes is too long, especially when waiting in 35 degrees weather without air condition, so I started to look for optimizations.
The bulk of the time is spent waiting for the elevator to come. The best case is when the elevator is on your floor and you get in, then the waiting time is zero. The worst case is when the elevator has just left and you have to wait a full cycle before you can get in. After you get in, it takes a fairly constant amount of time to reach your floor. Therefore, your travel time is determined by your luck with the elevator cycle. Assuming that the elevator takes 4 minutes to make a complete cycle (and you live on the top floor), the best case total elevator time is 2 minutes, the worst case is 6 minutes, and the average case is 4 minutes.
It occurred to me that just because I lived on the 14th floor, I don’t necessarily have to take the even numbered elevator! Instead, if the odd numbered elevator arrives first, it’s actually faster to take the elevator to the 13th floor and climb the stairs to the 14th floor. Compared to the time to wait for the elevator, the time to climb one floor is negligible. I started doing this trick and timed how long it took. Empirically, this optimization seemed to speed my time by about 1 minute on average.
Being a mathematician at heart, I was unsatisfied with empirical results. Theoretically, exactly how big is this improvement?
Let us model the two elevators as random variables and , both independently drawn from the uniform distribution . The random variables represent model the waiting time, with 0 being the best case and 1 being the worst case.
With the naive strategy of taking the even numbered elevator, our waiting time is with expected value . Using the improved strategy, our waiting time is . What is the expected value of this random variable?
For two elevators, the solution is straightforward: consider every possible value of and and find the average of . In other words, the expected value of is
Geometrically, this is equivalent to calculating the volume of the square pyramid with vertices at (0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0), and (1, 1, 1). Recall from geometry that the volume of a square pyramid with known base and height is .
Therefore, the expected value of is , which is a 33% improvement over the naive strategy with expected value .
Forget about elevators for now; let’s generalize!
We know that the expected value of two uniform random variables is , but what if we have n random variables? What is the expected value of the minimum of all of them?
I coded a quick simulation and it seemed that the expected value of the minimum of n random variables is , but I couldn’t find a simple proof of this. Searching online, I found proofs here and here. The proof isn’t too hard, so I’ll summarize it here.
Lemma: Let be the c.d.f for , where each is i.i.d with uniform distribution . Then the formula for is
Now to prove the main claim:
Claim: The expected value of is
Let be the p.d.f of , so . From this, the expected value is
This concludes the proof. I skipped a bunch of steps in the evaluation of the integral because Wolfram Alpha did it for me.
For some people, this sort of travel frustration would lead to complaining and an angry Yelp review, but for me, it led me down this mathematical rabbit hole. Life is interesting, isn’t it?
I’m not sure if the locals employ this trick or not: it was pretty obvious to me, but on the other hand I didn’t witness anybody else doing it during my stay. Anyhow, useful trick to know if you’re staying in the Chungking Mansions!
Read further discussion of this post on Reddit!