All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Probability
The First Repeat (Posted on 2016-07-18) Difficulty: 3 of 5
A bag has 5 tokens numbered 1 to 5. Tokens are drawn with replacement until a token is repeated. What is the probability that the repeated token is the first token drawn?

What is the formula for N tokens?

No Solution Yet Submitted by Brian Smith    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution | Comment 2 of 5 |
At the second draw, the probability of repeating the first draw is 1/5.

The probability that the second draw does not match but the third does is (4/5)*(1/5) = 4/25.

The probability that the second draw doesn't match the first and the third matches neither, but the fourth matches the first is (4/5)*(3/5)*(1/5).

The probability that none of the first four match but the 5th matches the first is (4/5)*(3/5)*(2/5)*(1/5)

The probability that none of the first five match but the 6th matches the first is (4/5)*(3/5)*(2/5)*(1/5)*(1/5).

The total of these is what's sought for part 1. That's 1569/3125.


In general:

Sigma{i=1 to n} n!/((n-i)!*n^(i+1))

A series of 100,000 simulation trials resulted in 50,106 successes:

50106 / 100000 =  .50106
 * 3125 =  1565.8125
 
also showing the proportion relative to 3125, the denominator of the calculated probability, is 1566 (rounded), which is close to the numerator. 

A table of probabilities, based on the formula is:

n   probability
2 .75
3 .62962962962963
4 .5546875
5 .50208
6 .462448559670782
7 .431162671530206
8 .405627250671387
9 .384257304987295
10 .366021568
11 .350215640976124
12 .336339472924913
13 .324026762534809
14 .31300210174168
15 .303053819009815
16 .294016140442042
17 .285757107105978
18 .278170172166272
19 .271168221103024
20 .264679229300045
21 .258643051588228
22 .253009010357279
23 .247734057345501
24 .242781354330108
25 .23811916424981
26 .233719975487927
27 .22955980343996
28 .225617628405121
29 .221874939396167
30 .218315361034434
31 .214924346199219
32 .211688921145929
33 .20859747281408
34 .205639570303766
35 .202805814210464
36 .200087708816626
37 .197477553147685
38 .194968347684308
39 .192553714136775
40 .190227826171372
41 .187985349362805
42 .185821388953309
43 .183731444245465
44 .181711368654649
45 .179757334608565
46 .177865802613113
47 .176033493911919
48 .174257366255849
49 .172534592372509
50 .170862540786879

finally a randomized set of 100,000 trials for n = 50:

16987 / 100000 =  .16987

DefDbl A-Z
Dim crlf$, had()


Private Sub Form_Load()
 Form1.Visible = True
 
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 Randomize Timer
 For tr = 1 To 100000
   ReDim had(5)
   r = Int(Rnd(1) * 5 + 1)
   had(r) = 1
   Do
     r = Int(Rnd(1) * 5 + 1)
     If had(r) Then
        If had(r) = 1 Then succ = succ + 1
        Exit Do
     End If
     had(r) = 2
   Loop
 Next
 Text1.Text = Text1.Text & succ & " / 100000 = " & Str(succ / 100000) & crlf
 Text1.Text = Text1.Text & " * 3125 = " & Str(succ * 3125 / 100000) & crlf
 
 Text1.Text = Text1.Text & crlf
 

 For n = 2 To 50
   Text1.Text = Text1.Text & n
   p = 0
   For i = 1 To n
     p = p + fact(n) / (fact(n - i) * n ^ (i + 1))
   Next
   Text1.Text = Text1.Text & Str(p) & crlf
 Next

 succ = 0 
  Randomize Timer
 For tr = 1 To 100000
   ReDim had(50)
   r = Int(Rnd(1) * 50 + 1)
   had(r) = 1
   Do
     r = Int(Rnd(1) * 50 + 1)
     If had(r) Then
        If had(r) = 1 Then succ = succ + 1
        Exit Do
     End If
     had(r) = 2
   Loop
 Next
 
 Text1.Text = Text1.Text & crlf
 Text1.Text = Text1.Text & succ & " / 100000 = " & Str(succ / 100000) & crlf
 
 
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Function fact(x)
  f = 1
  For i = 1 To x
    f = f * i
  Next
  fact = f
End Function


  Posted by Charlie on 2016-07-18 15:04:40
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information