Probability of opening a door with n-keys at the k-th trial.

I have a solution to this Problem in my book where two cases are considered. a) Discarding Keys b) not discarding Keys I managed he first part but i don't understand the given solution for b completely

The solution of b is given by: Let the sample space S be the collection of all the possible outcomes of m tries (m ≥ k). If we do not discard previously tried keys, the total number of sample points in S is ${ n }^{ m }$. And the number of the sample points in the event E={opening door at k-th trial} is ${ (n-1) }^{ k-1 }{ n }^{ m-k }$. Probability is than just dividing the oder of both sets. I don't understand how the get the number of sample points in E, could someone explain me how to get to this number

Edit : ] A woman has n keys, of which one will open her door. (a) If she tries the keys at random, discarding those that do not work, what is the probability that she will open the door on her kth try? (b) What if she does not discard previously tried keys

• The event E corresponds to choosing any key other that the correct one $k-1$ times (and the number of ways to do that is $(n-1)^{k-1}$), then choosing the correct one (and the number of ways to do that is $1$), then choosing any key $m-k$ times (and the number of ways to do that is $n^{m-k}$). Hence the formula. – Did Apr 18 '18 at 6:46
• @Did: That's clear enough, but from the way the problem is phrased, there's no sense in considering more than $k$ trials. In any case, this method yields the same, correct answer. – Shirish Kulhari Apr 18 '18 at 6:48
• There is every "sense in considering more than $k$ trials", actually, considering $m$ trials definitely simplifies the reasoning. – Did Apr 18 '18 at 6:52

we have n keys. assuming only one of those keys is the right key that opens the door. let's get an example to make it right. assume k = 4 and m = 10. so we try k-1 times to open the door and failed. so we got $(n-1)^{k-1=3}$. now on the k'th turn we open the door. and we got only 1 key that do it. so it is $(n-1)^{3}\times1$. we are on the k=4 try, so we got m-k=10-4=6 more tries. and we can choose any-key to "try" on our opened door. so we got $n^{m-k=6}$. all in all, $(n-1)^{k-1}\times1\times n^{m-k}$
Now, our trier, do her selection by random, which means - uniformly distributed. and the total number of possible outcomes, as you said, it is $n^m$. Now our space is Uniformly Distributed and Finite(!). It means that every point in our sample Space to have -the same probability to be realized as any other point. and we have a FINITE sample space (of size $n^m$). so 1 point in our sample space probability to be realized is $\frac{1}{n^m}$. 2-points it is $\frac{2}{n^m}$, etc... if $A\subset S$, is our event of "opening the door on the k'th try", as we calculated, the probability of a point in A to be realized is $\frac{|A|}{|S|}=\frac{|A|}{n^m}=\frac{(n-1)^{k-1}\times1\times n^{m-k}}{n^m}$.