# what's the probability that in a building of 10 floors and 5 people in elevator, the elevator would reach exactly until the 5th floor and no higher?

the question goes like this: "In a building of 10 floors, 5 people get inside an elevator on the entry floor. every one of them push independently a button of one of the 10 floors. what's the probability that the elevator would get exactly to the 5th floor and no higher?"

I thought of two ways to solve it, and each one gets me another result. so probably I do something wrong, would appreciate your help.

• first solution - let's choose the person that hits the 5th floor such that the elevator will reach this floor. $\binom{5}{1}$ options for that. for the rest, there're $5^4$ options to choose a floor. the probability space is $10^5$ for number of ways to choose floors (out of 10 floors) independently for 5 people. so the final result would be $\frac{\binom{5}{1} 5^4}{10^5}$

• second solution - let's notice there're $5^5$ ways to hit buttons in elevator such that the elevator would get at the most to 5th floor, and $4^5$ ways to hit buttons in elevator such that the elevator would get at the most to 4th floor. so the number of ways the elevator would reach exactly the 5th floor is $5^5-4^5$ and then the result is $\frac{5^5-4^5}{10^5}$

• Your first solution overcounts certain scenarios where multiple people choose the fifth floor. You can correct the count by breaking into cases based on how many people chose the fifth floor. $\binom{5}{1}4^4 + \binom{5}{2}4^3 +\binom{5}{3}4^2 +\binom{5}{4}4^1 +1$, which you should be able to see equals the numerator of the second approach – JMoravitz Aug 17 '16 at 11:18
• it's the number of ways of having all people from floors 1 to 5, but deduct from that the number of ways of having all people from floors 1 to 4 (because non of these work for you) - yes your second answer – Cato Aug 17 '16 at 11:37
• it's a good mental puzzle because there is 5 floors authorized, the 5th mandatory and 5 people ; I like to evaluate it with other values – user354674 Aug 17 '16 at 22:55

I think its easier to understand the difference if you simplify the example.

Assume you have 4 floors, 2 people, and you want to get the probability that the elevator would get exactly to the 2nd floor and no higher.

second solution would be $$\frac{2^2 - 1 ^2}{4^2} = \frac{3}{16},$$because there are 16 possible scenarios but only 3 lead exactly to the 2nd floor (namle 1-2, 2-1 and 2-2).

first solution You get $$\frac{\binom{2}{1} 2^1}{4^2} = \frac{4}{16}$$ because you count that the first persons hits floor 2 and the second person 1 or 2 (namely 2-1 and 2-2) plus the other case (namely 1-2 and 2-2). But you got the case 2-2 twice and this is why your first solution does not work.

Below is a simulation in R statistical software of a million iterations of this experiment, followed by the exact combinatorial result in your second solution. Here $X$ is the highest floor selected by any of the five passengers. A million iterations should give at least two to three place accuracy, so results are in substantial agreement.

m = 10^6; x = numeric(m)
for (i in 1:m) {
x[i] = max(sample(1:10, 5, rep=T)) }
mean(x==5)  # proportion of 5's
## 0.02105  # aprx P(X = 5)

(5^5 - 4^5)/10^5
## 0.02101   # exact P(X  = 5)


Here is a histogram of the simulated distribution of $X.$

Furthermore, the probability the elevator goes all the way to the top is $P(X = 10) = 1 - .9^5 = 0.40951,$ which agrees with the simulation within the margin of simulation error.

mean(x == 10)
## 0.408479


Horizontal red reference lines in the plot are at 0.0210 and 0.4095, the two probabilities mentioned above.

Simulated distribution (used for histogram):

table(x)/m
x
1        2        3        4        5
0.000011 0.000342 0.002143 0.007666 0.021050
6        7        8        9       10
0.046717 0.090376 0.159299 0.263917 0.408479

• I checked your results ; they are ok and very near from the computed ones – user354674 Aug 18 '16 at 0:49

Each person can choose one of 10 floors.

$10^{5}$ possible sets of desired floors.

possible sets where no one has chosen a floor higher than 5.

$5^5$ possible sets where no one has chosen a floor higher than 4.

$4^5$

$\frac {5^5-4^5}{10^{5}}$

This is the second solution... But, if it is an American building the elevator starts on floor 1. The first stop is 2.
$\frac {4^5-3^5}{9^5}$

We could get a little stupider and say that some people will take the stairs if going to floor 2 or 3, but that gets tricky to model.

As far as the flaw in the first solution JMoravits has it right, you are over-counting the number of people who want to go the the 5th floor.

$5\cdot 4^4 + 10\cdot 4^3 + 10\cdot 4^2 + 5\cdot 4 + 1$

Which you might recognize as looking similar to the expansion of: $(x+1)^5 - x^5$ and then setting $x = 4$ Or if this is an American elevator, setting $x = 3.$

• Extraneous complications. 'Entry level' is pretty clearly not meant to be one of the ten floors. A parking level perhaps. – BruceET Aug 17 '16 at 22:46