There are $N$ keys and $N$ locks. We test all keys at once.
What is the probability that $k$ keys are correctly matched to $k$ locks ($k \leq n$)?
Thanks a lot!
There are $N$ keys and $N$ locks. We test all keys at once.
What is the probability that $k$ keys are correctly matched to $k$ locks ($k \leq n$)?
Thanks a lot!
Copyright © 2021 JogjaFile Inc.
The number of permutations in $S_n$ which have $k$ fixed points will be $\binom{n}{k}\cdot !(n-k)$ where the subfactorial symbol $!r$ is in reference to the number of derangements of $r$ objects.
Assuming that exactly one key is tested per lock, we have then a probability getting exactly $k$ of the matching keys to their corresponding locks as being
$$\dfrac{!(n-k)\binom{n}{k}}{n!}$$