Probability of Getting 10 Pairs from a Box of 30 Socks

  • Thread starter juanitotruan77
  • Start date
  • Tags
    Probability
In summary, the conversation discusses a probability problem involving picking socks from a box containing 30 pairs. The question is to determine the most probable number of tries needed to get 10 pairs of socks. The conversation explores different approaches and equations, including the Gauss distribution, to solve the problem. It is suggested to lay out the sample space of all possible outcomes to better understand the problem. The conversation also discusses the conditions for an acceptable pair of socks and the difference between combinations and permutations. Ultimately, it is determined that finding the mode of the probability distribution will give the most probable number of tries needed to get 10 pairs of socks.
  • #36
juanitotruan77 said:
So i how do i do that?
You want the probability that the tth selection took you from r-1 pairs to r pairs. so first you had to have r-1 pairs after t-1 selections (for which you have a formula now), then the tth had to complete one more pair.
 
Physics news on Phys.org
  • #37
juanitotruan77 said:
Does the division affect the whole term or just the 2^(t-2r) ?
Since the other terms are just multiplied together, it should not make any difference.
 
  • #38
haruspex said:
Since the other terms are just multiplied together, it should not make any difference.

duh, yeah you're right. I redid the code and i got this result
Code:
1 -0.31666666666667
2 -0.010169491525424
3 -0.00049678550555231
4 -3.2811426579306E-5
5 -2.7464921801875E-6
6 -2.7964284016454E-7
7 -3.3660712242028E-8
8 -4.6900266694263E-9
9 -7.4409076966859E-10
10 -1.3263650083219E-10
11 -2.6262027164774E-11
12 -5.7169038726038E-12
13 -1.3547871156431E-12
14 -3.4590309335568E-13
15 -2.6318713624889E-13
16 -1.5573994348188E-12
17 -1.4601455216145E-11
18 -1.4060631661627E-10
19 -1.3993681163211E-9
20 1.4334985450147E-8
21 1.5051734735179E-7
22 8.0661860450918E-7
23 2.9292991423064E-6
24 8.0753652026503E-6
25 1.7945256006232E-5
26 3.3326904011481E-5
27 5.2930965194649E-5
28 7.2980573222738E-5
29 8.8184859310981E-5
30 9.3874205072845E-5
31 8.8184859310998E-5
32 7.29805732227E-5
33 5.2930965194717E-5
34 3.3326904011596E-5
35 1.7945256006425E-5
36 8.0753652023174E-6
37 2.9292991415367E-6
38 8.0661860563958E-7
39 1.5051734559838E-7
40 1.4334988312849E-8
41 1.3993583354239E-9
42 1.40595506151E-10
43 1.4544640215304E-11
44 1.6242406122789E-12
45 3.0078529857016E-13
46 1.4989134045413E-12
47 5.2256074460519E-12
48 2.0009163554113E-11
49 8.4622087530938E-11
50 3.9790950249657E-10
51 2.0969830781569E-9
52 1.2506737785137E-8
53 8.544642338361E-8
54 6.7913261182817E-7
55 6.4084817537707E-6
56 7.3825709803439E-5
57 0.0010812390414962
58 0.021468926553672
59 0.65
60 40
 
Last edited:
  • #39
haruspex said:
You want the probability that the tth selection took you from r-1 pairs to r pairs. so first you had to have r-1 pairs after t-1 selections (for which you have a formula now), then the tth had to complete one more pair.

So i have to multiply the result from the formula with the probability that i'll get the last sock in the tth draw?
 
  • #40
A minor issue but you need to fix your combination calculation so that if (t-2r) > (N-r), or if (t-2r) < 0 (and (N-r) > 0), then (N-r)C(t-2r) = 0 (this is how aCb is mathematically defined). This will fix the cases t= 0 through t = 19 and t = 41 through 60 where the probability should be zero.
 
Last edited:
  • #41
rcgldr said:
A minor issue but you need to fix your combination calculation so that if (t-2r) > (N-r), or if (t-2r) < 0 (and (N-r) > 0), then (N-r)C(t-2r) = 0 (this is how aCb is mathematically defined). This will fix the cases t= 0 through t = 19 and t = 41 through 60 where the probability should be zero.

Done
Code:
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 1.4334985450147E-8
21 1.5051734735179E-7
22 8.0661860450918E-7
23 2.9292991423064E-6
24 8.0753652026503E-6
25 1.7945256006232E-5
26 3.3326904011481E-5
27 5.2930965194649E-5
28 7.2980573222738E-5
29 8.8184859310981E-5
30 9.3874205072845E-5
31 8.8184859310998E-5
32 7.29805732227E-5
33 5.2930965194717E-5
34 3.3326904011596E-5
35 1.7945256006425E-5
36 8.0753652023174E-6
37 2.9292991415367E-6
38 8.0661860563958E-7
39 1.5051734559838E-7
40 1.4334988312849E-8
41 0
42 0
43 0
44 0
45 0
46 0
47 0
48 0
49 0
50 0
51 0
52 0
53 0
54 0
55 0
56 0
57 0
58 0
59 0
60 0
 
  • #42
juanitotruan77 said:
So i have to multiply the result from the formula with the probability that i'll get the last sock in the tth draw?
Yes. At this point, you have r-1 pairs and (t-1)-2(r-1) odd ones. The remaining 2N-t+1 socks consist of the same number of odd ones and N+r-t pairs. So what are the chances the next sock drawn will complete a pair?
 
  • #43
so let's take 30 for the example. If you have already 9 pairs in 29 tries, so there're 31 socks and you've 11 odd socks So you've 11 possible pairs with you. So the probability of you getting one of the 11 probable pairs is 31n11?
 
  • #44
juanitotruan77 said:
so let's take 30 for the example. If you have already 9 pairs in 29 tries, so there're 31 socks and you've 11 odd socks So you've 11 possible pairs with you. So the probability of you getting one of the 11 probable pairs is 31n11?
What is "31n11"? Do you mean 31C11? That would be the number of ways of choosing 11 things from 31, a huge number, and certainly not a probability.
As you say, there would be 31 socks left, and you want the prob of choosing one out of a particular 11 of them...
 
  • #45
haruspex said:
What is "31n11"? Do you mean 31C11? That would be the number of ways of choosing 11 things from 31, a huge number, and certainly not a probability.
As you say, there would be 31 socks left, and you want the prob of choosing one out of a particular 11 of them...

Yeah 31C11, sorry. mmm 11/31?
 
  • #46
juanitotruan77 said:
Yeah 31C11, sorry. mmm 11/31?

Yes. can you now generalise that using N, t, r?
 
  • #47
haruspex said:
Yes. can you now generalise that using N, t, r?
Having in mind that P(r, t) is the probability of having r-1 pairs in t-1 tries, then:
P(r, t) = NCr × (N-r)C(t-2r) × 2^(t-2r) / (2N)Ct
Q(r,t) = P(r, t) x ((t-1)-(2r-2)))/(2N-(t-1))
Just one more thing, why does that formula give me the probability of having r-1 in t-1 tries, and not r pairs in t tries if we're using t and r and not r-1 And t-1.
 
Last edited:
  • #48
I was checking my code and i noticed that i was doing something wrong. When i corrected it, it gave me the following:
Code:
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 7.1674927250735E-9
21 1.5051734722654E-7
22 1.6132372087358E-6
23 1.1717196568712E-5
24 6.460292162209E-5
25 0.00028712409609818
26 0.0010664609283647
27 0.0033875817724524
28 0.0093415133725204
29 0.022575323983591
30 0.048063592997323
31 0.090301295934364
32 0.14946421396033
33 0.21680523343696
34 0.27301399766135
35 0.29401507440453
36 0.26461356696408
37 0.19197454858178
38 0.10572511371171
39 0.039457219471355
40 0.0075156608516866
41 0
42 0
43 0
44 0
45 0
46 0
47 0
48 0
49 0
50 0
51 0
52 0
53 0
54 0
55 0
56 0
57 0
58 0
59 0
60 0
It seems its wrong, because I'm pretty sure that the one with the bigger probability should be 30 or 29
 
  • #49
juanitotruan77 said:
Having in mind that P(r, t) is the probability of having r-1 pairs in t-1 tries,
No, P(r, t) was defined as the probability of having r pairs in t tries. We want P(r-1,t-1): ##Q(r,t) = \frac{{^NC_r} ^{N-r}C_{t-2r} 2^{t-2r}}{^{2N}C_t}\frac{t+1-2r}{2N-t+1}##
To find the peak value in a unimodal sequence, just look for two consecutive terms that are about equal. Algebraically, that will all but cancel out all the factorials, leaving a relatively simple polynomial, probably a quadratic. Solving that will almost certainly give you a non-integer. The value you're looking for will be either the next integer up or the next one down.
 
  • #50
haruspex said:
No, P(r, t) was defined as the probability of having r pairs in t tries. We want P(r-1,t-1): ##Q(r,t) = \frac{{^NC_r} ^{N-r}C_{t-2r} 2^{t-2r}}{^{2N}C_t}\frac{t+1-2r}{2N-t+1}##
To find the peak value in a unimodal sequence, just look for two consecutive terms that are about equal. Algebraically, that will all but cancel out all the factorials, leaving a relatively simple polynomial, probably a quadratic. Solving that will almost certainly give you a non-integer. The value you're looking for will be either the next integer up or the next one down.
I didn't understand that, can you explain it, please?
 
  • #51
You have the expression for Q(r,t). We want the peak value as t varies. At the peak, consecutive terms will be about equal (same principle as finding maxima with calculus). So you write Q(r,t) = Q(r,t+1). Because of all the factorials involved (see the formula I posted for nCr), there will be a lot of cancellation of terms. When the smoke clears, you should have a relatively simple polynomial for t. This won't give a whole number, so try the whole numbers either side of what it does give. One of these two will be the peak term in the sequence.
 
  • #52
So i equal them and replace the values in the full formula with all the factorials? You said at the beggining that you got 27 by doing this, how? i tried and it didn't reduced to a cuadratic t term.
 
Last edited:
  • #53
haruspex said:
No, P(r, t) was defined as the probability of having r pairs in t tries. We want P(r-1,t-1): ##Q(r,t) = \frac{{^NC_r} ^{N-r}C_{t-2r} 2^{t-2r}}{^{2N}C_t}\frac{t+1-2r}{2N-t+1}##
Sorry, I forgot to edit the formula. I meant:
##Q(r,t) = \frac{{^NC_{r-1}} ^{N-r+1}C_{t+1-2r} 2^{t+1-2r}}{^{2N}C_{t-1}}\frac{t+1-2r}{2N-t+1}##
 
  • #54
haruspex said:
Sorry, I forgot to edit the formula. I meant:
##Q(r,t) = \frac{{^NC_{r-1}} ^{N-r+1}C_{t+1-2r} 2^{t+1-2r}}{^{2N}C_{t-1}}\frac{t+1-2r}{2N-t+1}##
Well, i did the Q(r,t) = Q(r,t+1)
and it gave me t=12.50842616853577.
I attached my Mathematica notebook with the procedure, but i can't find with I'm doing wrong.
 

Attachments

  • prob.pdf
    307.2 KB · Views: 221
Last edited:
  • #55
Starting with the same equations, when I do all the cancellation I wind up with t2-t-2N(2r-1) = 0. This gives t = 33.76. (My earlier answer of 27 was wrong.)
I checked it by generating Q(r,t) for t = 20 to 40 in a spreadsheet, and the peak is at t=34 (with prob=0.168).
Code:
t-1	Pr-1t-1	Qrt
19	0.0000	0.0000
20	0.0000	0.0000
21	0.0000	0.0000
22	0.0001	0.0000
23	0.0004	0.0001
24	0.0014	0.0002
25	0.0041	0.0008
26	0.0107	0.0025
27	0.0245	0.0067
28	0.0498	0.0156
29	0.0903	0.0320
30	0.1456	0.0583
31	0.2084	0.0934
32	0.2628	0.1314
33	0.2891	0.1606
34	0.2730	0.1680
35	0.2162	0.1470
36	0.1384	0.1038
37	0.0674	0.0556
38	0.0223	0.0202
39	0.0038	0.0038
(Note that the Q(r,t) add up to 1.)
Here are the cell formulae:
First column (t-1) starts at cell A4. Named cell _r1 represents r-1. These are the formulae in cells B4, C4:
=COMBIN(_N;_r1)*COMBIN(_N-_r1;$A4-2*_r1)*2^($A4-2*_r1)/COMBIN(2*_N;$A4)
=B4*(A4-2*_r1)/(2*_N-A4)
A4 contains 19. A5 etc. increment from there.
 
  • #56
haruspex said:
Starting with the same equations, when I do all the cancellation I wind up with t2-t-2N(2r-1) = 0. This gives t = 33.76. (My earlier answer of 27 was wrong.)
I checked it by generating Q(r,t) for t = 20 to 40 in a spreadsheet, and the peak is at t=34 (with prob=0.168).
Code:
t-1	Pr-1t-1	Qrt
19	0.0000	0.0000
20	0.0000	0.0000
21	0.0000	0.0000
22	0.0001	0.0000
23	0.0004	0.0001
24	0.0014	0.0002
25	0.0041	0.0008
26	0.0107	0.0025
27	0.0245	0.0067
28	0.0498	0.0156
29	0.0903	0.0320
30	0.1456	0.0583
31	0.2084	0.0934
32	0.2628	0.1314
33	0.2891	0.1606
34	0.2730	0.1680
35	0.2162	0.1470
36	0.1384	0.1038
37	0.0674	0.0556
38	0.0223	0.0202
39	0.0038	0.0038
(Note that the Q(r,t) add up to 1.)
Here are the cell formulae:
First column (t-1) starts at cell A4. Named cell _r1 represents r-1. These are the formulae in cells B4, C4:
=COMBIN(_N;_r1)*COMBIN(_N-_r1;$A4-2*_r1)*2^($A4-2*_r1)/COMBIN(2*_N;$A4)
=B4*(A4-2*_r1)/(2*_N-A4)
A4 contains 19. A5 etc. increment from there.

The thing is that my physics teacher told me that the answer has to be near 28, that's why I'm so frustrated. I think it has something to do with the fact that you might be considering that the array of posibilities is a binary tree but you can't have a pair in your next move without another not pair sock so is something like
 

Attachments

  • tree.jpg
    tree.jpg
    20.2 KB · Views: 363
Last edited:
  • #57
I did simulate this and I got

Code:
20 0.000:
21 0.000:
22 0.000:
23 0.000:
24 0.000:
25 0.000:
26 0.001:
27 0.003:*
28 0.009:****
29 0.020:**********
30 0.040:********************
31 0.069:**********************************
32 0.105:****************************************************
33 0.140:*********************************************************************
34 0.160:********************************************************************************
35 0.158:******************************************************************************
36 0.131:*****************************************************************
37 0.089:********************************************
38 0.048:***********************
39 0.019:*********
40 0.005:**
41 0.001:
 
  • #58
jfgobin said:
I did simulate this and I got

Code:
20 0.000:
21 0.000:
22 0.000:
23 0.000:
24 0.000:
25 0.000:
26 0.001:
27 0.003:*
28 0.009:****
29 0.020:**********
30 0.040:********************
31 0.069:**********************************
32 0.105:****************************************************
33 0.140:*********************************************************************
34 0.160:********************************************************************************
35 0.158:******************************************************************************
36 0.131:*****************************************************************
37 0.089:********************************************
38 0.048:***********************
39 0.019:*********
40 0.005:**
41 0.001:
Ohhh i made a mistake in the code, i didn't think that the random number generator could generate more than 1 pair of the same kind of socks. You're both right, and THANKS A LOT FOR ALL YOUR HELP, especially to haruspex for having me so much patience.
 
Last edited:
  • #59
juanitotruan77 said:
Ohhh i made a mistake in the code, i didn't think that the random number generator could generate more than 1 pair of the same kind of socks. You're both right, and THANKS A LOT FOR ALL YOUR HELP, especially to haruspex for having me so much patience.
It was an interesting journey, and I hope it was useful for you. (You can no longer claim to know nothing about probability!)
 
  • #60
haruspex said:
It was an interesting journey, and I hope it was useful for you. (You can no longer claim to know nothing about probability!)

yeah, I've learn more probability here in 5 days than in 6 months of school, thanks!
 
  • #61
It was a learning experience for me as well. What class was this that you got this problem from?
 
  • #62
rcgldr said:
It was a learning experience for me as well. What class was this that you got this problem from?
Thanks to you too! Physics, my physic's teacher is a very good teacher.
 

Similar threads

  • Precalculus Mathematics Homework Help
Replies
24
Views
1K
  • Precalculus Mathematics Homework Help
Replies
16
Views
2K
  • Calculus and Beyond Homework Help
Replies
3
Views
738
  • Precalculus Mathematics Homework Help
Replies
11
Views
3K
  • Precalculus Mathematics Homework Help
Replies
12
Views
2K
  • Precalculus Mathematics Homework Help
Replies
5
Views
4K
  • Precalculus Mathematics Homework Help
Replies
2
Views
1K
  • Advanced Physics Homework Help
Replies
11
Views
1K
Replies
2
Views
1K
Back
Top