this is a test

## Archive for the ‘examples’ Category

## Random Keys

Posted: March 28, 2011 in examples, probabilityTags: binomial coefficient, expectation, fundamental counting principle, math, probability, probability mas function

**Given possible keys where they are all equally likely to be chosen. If only 3 keys are correct, then on average how many keys would I have to try to find a correct one?**

First lest try to clarify the problem by picturing the following scenario. We have a bucket with keys and we would like to open a door but only 3 keys will work. We randomly choose a key and try to open the door. If the door opens then we are done; but if it doesn’t open then we randomly choose *another* key and so on. Now if we were to attempt to open this door then we would expect to do so after trying keys, where is some number between 1 and . So if a friend were to attempt to open this door then we would expect some number between 1 and , and from a kth friend we would get a some number also between between 1 and . Hence, we could argue that on average we would need to try keys to find the correct one, but each is a random variable so if we were to repeat this experiment then we might get a different average! However, if is a large number then we would expect any experimental averages to be close to each other, and if we let approach infinity then these averages would converge to the expected value.

So we are interested in calculating the expected value but first we need to derive a probability mass function which would tell us the probability of finding the correct key on the kth try, Then the expected value will be given by

For we are interested in

P(finding correct key on 1st try)

which is given by

Since there are 3 correct keys then there are 3 ways in which the 1st choice could be a correct key. And, since there are keys then there are ways in which 1st key could be chosen. So

For we are interested in

P(finding correct key on 2nd try)

which can be thought of as

P(1st key was not correct and 2nd key is correct)

which is given by

Since there are ways in which 1st choice could be incorrect and 3 ways in which 2nd choice could be correct then by the fundamental principle of counting there are ways in which 1st key could be incorrect and 2nd correct. Similarly, since there are ways in which the 1st key could be chosen and ways in which 2nd key could be chosen then thre are ways in which 1st and 2nd keys could be chosen. So,

If follows that

so in general

which can be simplified to

where the binomial coefficient is defined to be coefficient of the of in the polynomial expansion of

So the average number of keys we would have to try, to find a correct key would be given by

which results in