My Math Forum What is the probability of getting the same number twice?
 User Name Remember Me? Password

 Probability and Statistics Basic Probability and Statistics Math Forum

 June 16th, 2017, 11:34 AM #11 Math Team     Joined: Jul 2013 From: काठमाडौं, नेपाल Posts: 872 Thanks: 60 Math Focus: सामान्य गणित i would think it this way: Since I have 24 draws, I would take 23 different numbers in my first 23 draws and 1 among those 23 numbers in my 24th draw. In 1st draw we can take any number but in the following draws we cannot take numbers which are already drawn, thus the numerator of the probabilities are decreasing by 1 in each of the following draw. Thus the probability of getting 23 different numbers in the first 23 draw is: $\displaystyle P1 = \frac{255}{255}\times \frac{254}{255}\times \frac{253}{255}\times ......$ till 23 steps $\displaystyle P1 = \frac{255!}{255^{23}\times 232!}$ Then for the 24th draw, we have to draw one of the numbers which we have already drawn. There are 23 possible numbers which we can draw out of 255 numbers. Thus the probability of having such number in 24th draw is: $\displaystyle P2=\frac{23}{255}$ Hence, the total probability is: $\displaystyle P=P1 \times P2$ $\displaystyle P= \frac{255!\times 23}{255^{24}\times 232!}$ $\displaystyle P\approx 0.0324$ Thanks from JeffM1
 June 16th, 2017, 11:57 AM #12 Senior Member   Joined: Dec 2012 From: Hong Kong Posts: 853 Thanks: 311 Math Focus: Stochastic processes, statistical inference, data mining, computational linguistics I'd like to present an alternative approach to the problem that could possibly shed light on that number. Consider the Markov chain with states 0, 1, ... 7, where state 0 is the initial state where no numbers have been chosen, states i, $\displaystyle 1 \leq i \leq 6$ denote the state where i distinct numbers have been chosen and no repeats have appeared so far, and 7 denote the state where repeats have appeared. Obviously, the transition matrix is as follows: $\displaystyle \mathbf{P} = \begin{bmatrix} 0 &1 &0 & 0 & 0 & 0 & 0 & 0\\ 0 &0 & \frac{5}{6} & 0 & 0& 0& 0& \frac{1}{6}\\ 0 & 0 & 0 & \frac{2}{3} & 0 & 0 &0 & \frac{1}{3}\\ 0 & 0 &0 &0 & \frac{1}{2}& 0 & 0& \frac{1}{2}\\ 0 & 0 & 0& 0 & 0 &\frac{1}{3} & 0 & \frac{2}{3}\\ 0 & 0 & 0 & 0 & 0 & 0 & \frac{1}{6} & \frac{5}{6}\\ 0& 0 & 0 & 0 & 0 & 0 &0 &1 \\ 0&0 & 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix}$ and the initial distribution is $\displaystyle \mathbf{e}_1$. So all we have to do is to calculate $\displaystyle \mathbf{e}_1\mathbf{P}^3 = (0,0,0,\frac{5}{9},0,0,0,\frac{4}{9})^T$, verifying Jeff's answer. Using a well-known theorem on absorbing states and some concepts in elementary probability (in particular the probability generating function), we can even do other cool things like determining how many numbers we need to draw on average to get a repeat, but I digress. So we can immediately apply this to the initial question: $\displaystyle \mathbf{P} =\begin{bmatrix} 0 & 1 & 0 & ... & 0 & 0\\ 0 & 0 & 254/255 & ... & 0& 1/255\\ 0 & 0 & 0 & \ddots & 0 & \vdots\\ 0& 0 & 0 & ... & 0 & 1\\ 0 & 0 & 0 & ...& 0 &1 \end{bmatrix}$ MATLAB tells us that 25th and last entries of $\displaystyle \mathbf{e}_1 \mathbf{P}^{24}$ are 0.32719 and 0.67281 respectively, again verifying Jeff's claims. Thanks from JeffM1 Last edited by 123qwerty; June 16th, 2017 at 11:59 AM.
 June 16th, 2017, 01:00 PM #13 Math Team   Joined: Oct 2011 From: Ottawa Ontario, Canada Posts: 10,908 Thanks: 716 I stick to my guns: the probability is ~.39
June 16th, 2017, 01:24 PM   #14
Senior Member

Joined: May 2016
From: USA

Posts: 825
Thanks: 335

Quote:
 Originally Posted by Denis Well, whatever... IF, IF, IF the 24 draws produce: 1 pair no other number matching that pair 22 remaining are ALL different then probability = ~.39
I agree that that is the apparent question originally asked.

How many ways can I draw 24 cards with replacement from a set of 255 cards consecutively numbered 1 through 255?

Answer: $255^{24}.$

Do you agree?

How many ways can I draw 23 differently numbered cards from that same set with replacement?

Answer: $\displaystyle \prod_{j=1}^{23}(256 - j).$

Do you agree?

How many ways can I draw one of 23 specific numbers from that set?

Answer: $23.$

Do you agree?

So the probability of drawing 23 different cards and 1 duplicate card in 24 draws with replacement should be

$\dfrac{23 * \displaystyle \prod_{j=1}^{23}(256 - j)}{255^{24}} \approx 0.0324.$

I can't get to your result.

June 16th, 2017, 03:09 PM   #15
Math Team

Joined: Jul 2013
From: काठमाडौं, नेपाल

Posts: 872
Thanks: 60

Math Focus: सामान्य गणित
Quote:
 Originally Posted by JeffM1 I agree that that is the apparent question originally asked. How many ways can I draw 24 cards with replacement from a set of 255 cards consecutively numbered 1 through 255? Answer: $255^{24}.$ Do you agree? How many ways can I draw 23 differently numbered cards from that same set with replacement? Answer: $\displaystyle \prod_{j=1}^{23}(256 - j).$ Do you agree? How many ways can I draw one of 23 specific numbers from that set? Answer: $23.$ Do you agree? So the probability of drawing 23 different cards and 1 duplicate card in 24 draws with replacement should be $\dfrac{23 * \displaystyle \prod_{j=1}^{23}(256 - j)}{255^{24}} \approx 0.0324.$ I can't get to your result.
i absolutely agree with you.

 June 16th, 2017, 04:04 PM #16 Senior Member   Joined: May 2016 From: USA Posts: 825 Thanks: 335 I am impressed by 123qwerty's translation into Markov processes even though I have almost no recollection of how to work with them. It certainly looks to be more powerful than my way. Obviously my way and mathematician's way are mathematically identical although I flatter myself that my explanation may be slightly more intuitive. Of course I could not give an explanation in Nepali at all. Denis, mon ami, if you still are not convinced, I suggest that you try to give the reasoning that leads to your result.
 June 16th, 2017, 04:33 PM #17 Math Team   Joined: Oct 2011 From: Ottawa Ontario, Canada Posts: 10,908 Thanks: 716 I was kinda kidding...didn't want to admit I had badly programmed my simulation runs... Yes yes...I'm heading for the corner...
June 16th, 2017, 05:18 PM   #18
Senior Member

Joined: May 2016
From: USA

Posts: 825
Thanks: 335

Quote:
 Originally Posted by Denis I was kinda kidding...didn't want to admit I had badly programmed my simulation runs... Yes yes...I'm heading for the corner...
I probably will be joining you there soon enough.

 June 18th, 2017, 10:27 AM #19 Math Team   Joined: Oct 2011 From: Ottawa Ontario, Canada Posts: 10,908 Thanks: 716 To: Probability Prof. Jeff From: student Denis If problem changed to 1 to 9 (instead of 1 to 255) and to 4 picks (instead of 24), everything else remaining same, then: total combos = 9^4 combos with 1 pair + 2 diff. numbers: 3024 probability: 3024/9^4 = .460905... OR: 1 * 8/9 * 7/9 * 3/9 * 2 = .460905... Do I visit the corner again?
June 19th, 2017, 10:58 PM   #20
Senior Member

Joined: Jul 2012
From: DFW Area

Posts: 603
Thanks: 83

Math Focus: Electrical Engineering Applications
Respectfully to All,

I think that the answer to the problem as stated (exactly one matching pair with no repeats) is ~0.38924, or precisely:

$\displaystyle \large \frac{255!}{232! \cdot 255^{24}} \cdot \frac{24!}{2! \cdot 22!}$

Notice that this is exactly 12 times the agreed upon value, given approximately as 0.0324, because:

$\displaystyle \large \frac{24!}{2! \cdot 22!} = 12 \cdot 23$

Please permit me to:
1) Show an inconsistency in the analysis of the agreed upon result.
2) Explain my concept of the solution.
3) Demonstrate the concept using what I think is the simplest example.
4) Provide a little background as to my interest in this.

So, for 1):

Quote:
 How many ways can I draw 23 differently numbered cards from that same set with replacement? Answer: $\displaystyle \large \prod_{j=1}^{23}(256 - j).$ Do you agree? How many ways can I draw one of 23 specific numbers from that set? Answer: 23.
So we have, I think:

$\displaystyle 255 \cdot 254 \cdot 253 \cdot \ldots \cdot 234 \cdot 233 \cdot 23$

If that is the case, then in the simplified example given earlier in the thread:

Quote:
 Two numbers the same (be careful: the different number can come first, second or third) = $\displaystyle 6∗5∗3=90.$
Why isn't that 3 a 2?

By the logic given in the first quote above, we can match 2 specific numbers here, not 3. But as is cautioned, it is not the number of numbers that is important, it is the number of places that is important. This appears to be inconsistent to me.

So for 2):

I would word it differently: It is the number of combinations of 3 numbers taken two at a time (the two types are numbers that match and the numbers that do not match):

$\displaystyle \large \frac{3!}{2! \cdot 1!}=3$

So to explain my solution, for the first number we have our choice of 255. Then let's match it 'right off the bat' with the second number so we have a choice of 1, then we can't match any more so we count down from there:

$\displaystyle \large 255 \cdot 1 \cdot 254 \cdot 253 \cdot \ldots \cdot 234 \cdot 233$

Obviously, we still have two types of numbers, the matching ones, and the non-matching ones, which gives the multiplication by:

$\displaystyle \large \frac{24!}{2! \cdot 22!} = 12 \cdot 23$

for the various combinations.

For 3) let's try to simplify things as much as we can. Let's have 3 symbols and take 4 of the symbols and calculate how many combinations exactly two of the symbols appear in.

I think that it is:

$\displaystyle \large 3 \cdot 1 \cdot 2 \cdot 1 \cdot \frac{4!}{2! \cdot 2!}=36$

If I am not mistaken, by the method of calculation as described in the thread the number is:

$\displaystyle \large 3 \cdot 2 \cdot 1 \cdot 3=18$

So let's just list them using symbols 0,1,2. Taking 2 as the repeated symbol, in ascending order we have:

0122
0212
0221
1022
1202
1220
2012
2021
2102
2120
2201
2210

So we have 12 combinations with the 2 repeated. We can have the 0 and 1 repeated as well so we have 3*12=36 (not 18 ).

For 4), I became interested in this type of thing because at my place of employment, in order to log in remotely, we have to enter a code that is chosen at random, 6 each of the digits 0-9.

I noticed that it was relatively rare to have no repeated digits so I tried to figure out the odds of getting exactly two repeating digits (among other things). I wrote programs in Ruby (which I will gladly share but I doubt anyone uses Ruby here) to run random numbers and looking at the percentage, and also to calculate exactly by running through all of the combinations and looking at the percentage.

I am pretty sure that I used reasoning similar to that given earlier in the thread but the calculated results did not match the programs' outputs until I used the methods given above.

Caveat: My 'exactly two matching numbers' routine may be flawed but for base 3 with 4 symbols taken, it does give 36, in agreement with the result above. For base 10 and 6 numbers taken it gives 453600 which agrees with:

$\displaystyle \large 10 \cdot 1 \cdot 9 \cdot 8 \cdot 7 \cdot 6 \cdot \frac{6!}{2! \cdot 4!}$

My random number calculating program calculates ~0.39 for the stated problem, in agreement with the calculation (and Denis' initial result, which I think is correct).

 Tags number, probability

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post JDSimpkins Probability and Statistics 9 April 27th, 2015 07:01 AM meghraj Probability and Statistics 9 November 8th, 2012 07:00 PM eliotjames Advanced Statistics 3 October 7th, 2012 04:02 PM ershi Number Theory 113 August 18th, 2012 05:45 AM hoyy1kolko Probability and Statistics 3 June 4th, 2011 05:38 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top