# probability of correctly guessing 1,2,3 or 4 digits out of 4 digit number

• Oct 26th 2012, 03:50 PM
wicksteed
probability of correctly guessing 1,2,3 or 4 digits out of 4 digit number
I have two questions and it's a little more complicated than the title implies. I just spent almost 2 hours reviewing basic probability and reading lottery-related websites and I just don't have time to keep going with this on my own (I'm making a game and it's nothing to do with lotteries actually).

First let's say there's a random 4 digit number that can go from 0000 to 9999. A guesser is trying to guess the right numbers before seeing them. But it would be a "box play" in the lingo of the lottery, ie guessing the correct numbers but the numbers can appear in any order. So the guesser would win if he or she guessed 3456 and the generated number turns out to be 4365.

1)What is the probability of the guesser making a 4-digit guess but only 1 of his digits appear in the actual 4-digit generated number? What about for 2,3, or 4 of his guessed numbers turning up in the actual generated 4-digit number?

2) What if the goal of the guesser is to guess a number that is similar to the actual number. Let me explain. Let's say that the guesser guesses that the actual number is 6214. The actual number turns out to be 6114. Because there are two 1's, the guess that was made is more similar to the actual number than if the actual number was 6134. Is there a fairly easy way of calculating the probability of that level of similarity?

I think the probability for question number one is likely pretty easy to calculate, but I want to be sure I know the answer. For question number two, I think that might be complicated. Is there a formula or online tool for helping?

• Oct 26th 2012, 05:09 PM
chiro
Re: probability of correctly guessing 1,2,3 or 4 digits out of 4 digit number
Hey wicksteed.

For number 2, this question is a little too vague to give a precise answer.

For number 1, you need to consider the possibility that 0, 1, 2, 3, and 4 unique digits exist. We can treat this as a binomial and if every digit has the same likelihood then probability of getting that particular digit is 1/10 and not getting it is 9/10 providing that every digit is independent and has the same distribution.

For the one digit scenario we have a Binomial distribution with n = 4 and p = 1/10 (probability of getting that 1 digit in one slot).

If you can only get one correct digit in any slot, the probability is 4*(1/10)*(9/10)^3. If you can that unique digit twice the probability is 6*(1/10)^2*(9/10)^2, three times its 4*(1/10)^3*(9/10) and if the unique digit is in every digit of the number the probability is (1/10)^4.

If you want to add these all up, the probability is 1 - (9/10)^4.
• Oct 26th 2012, 05:10 PM
Shakarri
Re: probability of correctly guessing 1,2,3 or 4 digits out of 4 digit number
1)
If he picks 4 different numbers then those numbers can be made into 4P4 numbers (short for 4 pick 4, the nPr button on your calculator) there are 10^4 combinations of numbers in total so the chance of him being correct is 4P4/10000
It would be different if his numbers were 2344 because there are fewer ways of rearranging those numbers, 3*(3P3) ways actually, similarly if he chose 2 or 1 unique numbers the number of arrangements would be 2*2P2 and 1*1P1
• Oct 27th 2012, 07:14 AM
wicksteed
Re: probability of correctly guessing 1,2,3 or 4 digits out of 4 digit number
Thanks.

Is the following a correct way of doing it? This is how I did it originally.

There's a 4 digit number. The odds of getting the first digit right are 1/10. But it would be considered a hit if your guessed number appears in any of the four digits. So you take 10 and divide by 4 which equals 2.5. Odds are 1/2.5. This seems intuitively right because it's easy to see how if there were 5 digits the probability of the digit appearing in any would be 50%. 10% * 5.

For the odds of 2 of your guesses digits appearing in the number you'd note that there's 1/10 odds for it to appear in any one slot and since there's now three remaining slots it's 10/3=3.33 for the odds of that second one also appearing in one of the three remaining slots. Now you multiply them. So it's 1 in 8.33 for 2 of your guessed digits appearing in any of the slots in the 4-digit number.

Then you do the same thing for the last two remaining digits to see what the odds would be of guessing all 4 digits correctly if they can appear in any order. That comes out to 1 in 416.667. And this webpage for a lottery says that's true if you scroll halfway down. But I'm not sure if I arrived at that 416.667 number the same way they did and so I don't know if my 1/2.5 and 1/8.33 odds are valid.
• Oct 27th 2012, 11:07 AM
Shakarri
Re: probability of correctly guessing 1,2,3 or 4 digits out of 4 digit number
1 in 416.667 is the same as the solution I posted for when 4 unique numbers are picked. However if 2 or more of the chosen numbers were the same then your method would need some adjusting, I am not sure how you could adapt your method to suit a guess like 2234 but my solution of 3*3P3/10000 should still be valid if a number is chosen twice.
• Oct 28th 2012, 12:25 PM
wicksteed
Re: probability of correctly guessing 1,2,3 or 4 digits out of 4 digit number
OK, thanks a lot for your help. I'm using this site: Permutations Calculator (nPr) and will this method to try and make sense of the scenario where there are repeating numbers in the actual number.