Riddler

# The Elevator Button Puzzle

A solution to this week's riddle by fivethirtyeight.com.

Here is this week’s ridde from fivethirtyeight.com:

In a building’s lobby, some number (N) of people get on an elevator that goes to some number (M) of floors. There may be more people than floors, or more floors than people. Each person is equally likely to choose any floor, independently of one another. When a floor button is pushed, it will light up.

What is the expected number of lit buttons when the elevator begins its ascent?

This is an expected value problem, and the obvious wrinkle is that multiple people may get off on the same floor. So, we can also think of this as a sort of sampling of floors *with replacement*. But before we determine the expected value, we can simulate this scenario for many buildings. Doing this for a thousand buildings should be more than enough. So for a thousand buildings, let’s randomly generate a number of floors and elevator riders. Each building has between one and a thousand floors (a very tall building!), and each elevator has between one and a thousand riders (a very big elevator!).

On average, about 62% of buttons will be pressed. But, can we get the same result without simulating the problem? Some advice by Andre Nicolas gives us a good starting point.

For to , let a random variable if is chosen at least once, i.e., if at least one rider presses the button for this floor, and let otherwise.

For any single rider pressing a button, the probability of **not** choosing is equal to . Therefore, for multiple riders, where each may or may not select a floor already selected by another rider, we get:

The number of floors selected, i.e., buttons pressed, is then the sum over all floors. Let’s call the total number of buttons pressed .

So by the linearity of expectation we then get the expected value:

To get the percent of buttons pressed in expectation, we then just divide though by . Let’s do this for the thousand buildings in our simulation and see if we get the same answer.

Indeed, we get the same mean and standard deviation. There is also a nearly perfect correlation (showing we got the ‘right’ answer) between the simulated percent and the expected value percent. This can be easily seen in a plot of both.

Therefore, if you have a meeting at the top of a very tall building, and there are many other riders in your elevator with very random preferences about where to get off, be prepared for a rather long ride.

RnotR PROBABILITY · EXPECTATION

riddler