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

 Best guess (Posted on 2015-07-30)
A player draws from a bag containing 10 black and 10 white marbles one by one, without putting them back in.
Every time before drawing a marble he guesses the color of the marble he will draw.
He decides to always guess the color that occurs most frequently remaining in the bag (if there is a tie, he chooses either color).

Find the expected number of correct guesses.

Find a formula for the number of correct guesses for starting with X black and Y white marbles.

This problem is a modified version of Guessing suit and addresses an interesting question that came up in the comments.

 No Solution Yet Submitted by Jer No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 1 of 3
The expected number for 10 white and 10 black marbles is 1139735 / 92378 ~= 12.3377319275152.

Starting with UBASIC, as it can do rational numbers: We build up a table so that the probability for higher numbers of marbles can be based on the probabilities of smaller numbers and the probability that the larger number will go to the particular smaller numbers.

4   kill "bestgues.txt"
5   open "bestgues.txt" for output as #2
10   dim State(14,14)
20   for I=0 to 14:State(I,0)=I:next
30   for I=0 to 14:State(0,I)=I:next
40   for Tot=2 to 28
50   for White=1 to 14
60      Black=Tot-White
70      if Black<=14 and Black>=0 then
80        :if Black>White then
85         :if White>0 then
90          :State(White,Black)=(White//(White+Black))*State(White-1,Black)+(Black//(White+Black))*(State(White,Black-1)+1)
91          :else
92           :State(White,Black)=(Black//(White+Black))*(State(White,Black-1)+1)
95         :endif
100        :else
105         :if Black>0 then
110         :State(White,Black)=(Black//(White+Black))*State(White,Black-1)+(White//(White+Black))*(State(White-1,Black)+1)
111         :else
112         :State(White,Black)=(White//(White+Black))*(State(White-1,Black)+1)
115         :endif
120     :endif
130   next White
140   next Tot
150   for White=0 to 14
160   for Black=0 to 14
170        print State(White,Black);
172        print #2,State(White,Black);
180   next
190   print:print
192   print #2,:print #2,
200   next
205   close #2

Each row below represents a different number of white marbles from 0 to 14. In each row, the expected values are in the order from zero black marbles to 14 black marbles. If one of the colors has zero representation in the set of marbles, then of course, you get all the marbles, as shown on the first line and the first entry in each line.  The doubled slashes of UBASIC have been replaced by the single slashes commonly associated with fractions:

0  1  2  3  4  5  6  7  8  9  10  11  12  13  14

1  3/2  7/3  13/4  21/5  31/6  43/7  57/8  73/9  91/10  111/11  133/12  157/13  183/14  211/15

2  7/3  17/6  18/5  67/15  113/21  177/28  131/18  371/45  507/55  673/66  436/39  1107/91  1381/105  1697/120

3  13/4  18/5  41/10  169/35  317/56  275/42  112/15  1387/165  2059/220  1476/143  2055/182  5581/455  7417/560  4837/340

4  21/5  67/15  169/35  373/70  380/63  718/105  1271/165  4259/495  6813/715  10480/1001  5197/455  22537/1820  15887/1190  10957/765

5  31/6  113/21  317/56  380/63  823/126  1667/231  3169/396  11389/1287  19489/2002  10657/1001  16855/1456  38735/3094  14429/1071  41957/2907

6  43/7  177/28  275/42  718/105  1667/231  3565/462  3598/429  27497/3003  49989/5005  86965/8008  72769/6188  58846/4641  92345/6783  28217/1938

7  57/8  131/18  112/15  1271/165  3169/396  3598/429  7625/858  61429/6435  117853/11440  108129/9724  95311/7956  162113/12597  53411/3876  42752/2907

8  73/9  371/45  1387/165  4259/495  11389/1287  27497/3003  61429/6435  129293/12870  130008/12155  250292/21879  462793/37791  164962/12597  284381/20349  475738/31977

9  91/10  507/55  2059/220  6813/715  19489/2002  49989/5005  117853/11440  130008/12155  272171/24310  546773/46189  211151/16796  392909/29393  706683/49742  1232163/81719

10  111/11  673/66  1476/143  10480/1001  10657/1001  86965/8008  108129/9724  250292/21879  546773/46189  1139735/92378  1143934/88179  4428771/323323  8285509/572033  5006119/326876

11  133/12  436/39  2055/182  5197/455  16855/1456  72769/6188  95311/7956  462793/37791  211151/16796  1143934/88179  2376047/176358  9533581/676039  6165043/416024  5793593/371450

12  157/13  1107/91  5581/455  22537/1820  38735/3094  58846/4641  162113/12597  164962/12597  392909/29393  4428771/323323  9533581/676039  19743201/1352078  19795204/1300075  38476058/2414425

13  183/14  1381/105  7417/560  15887/1190  14429/1071  92345/6783  53411/3876  284381/20349  706683/49742  8285509/572033  6165043/416024  19795204/1300075  40890483/2600150  81966691/5014575

14  211/15  1697/120  4837/340  10957/765  41957/2907  28217/1938  42752/2907  475738/31977  1232163/81719  5006119/326876  5793593/371450  38476058/2414425  81966691/5014575  168947957/10029150

For decimal probabilities, in a more neat format, switching to Visual Basic 5.0.  The VB version also includes a simulation for 10,10 and 3.6:

`         0        1        2        3        4        5        6        7        8        9       10       11       12       13       14 0   0.00000  1.00000  2.00000  3.00000  4.00000  5.00000  6.00000  7.00000  8.00000  9.00000 10.00000 11.00000 12.00000 13.00000 14.00000 1   1.00000  1.50000  2.33333  3.25000  4.20000  5.16667  6.14286  7.12500  8.11111  9.10000 10.09091 11.08333 12.07692 13.07143 14.06667 2   2.00000  2.33333  2.83333  3.60000  4.46667  5.38095  6.32143  7.27778  8.24444  9.21818 10.19697 11.17949 12.16484 13.15238 14.14167 3   3.00000  3.25000  3.60000  4.10000  4.82857  5.66071  6.54762  7.46667  8.40606  9.35909 10.32168 11.29121 12.26593 13.24464 14.22647 4   4.00000  4.20000  4.46667  4.82857  5.32857  6.03175  6.83810  7.70303  8.60404  9.52867 10.46953 11.42198 12.38297 13.35042 14.32288 5   5.00000  5.16667  5.38095  5.66071  6.03175  6.53175  7.21645  8.00253  8.84926  9.73477 10.64635 11.57624 12.51939 13.47246 14.43309 6   6.00000  6.14286  6.32143  6.54762  6.83810  7.21645  7.71645  8.38695  9.15651  9.98781 10.85977 11.75970 12.67959 13.61418 14.55986 7   7.00000  7.12500  7.27778  7.46667  7.70303  8.00253  8.38695  8.88695  9.54608 10.30184 11.11981 11.97976 12.86918 13.77993 14.70657 8   8.00000  8.11111  8.24444  8.40606  8.60404  8.84926  9.15651  9.54608 10.04608 10.69585 11.43983 12.24612 13.09534 13.97518 14.87751 9   9.00000  9.10000  9.21818  9.35909  9.52867  9.73477  9.98781 10.30184 10.69585 11.19585 11.83773 12.57151 13.36743 14.20697 15.0780510  10.00000 10.09091 10.19697 10.32168 10.46953 10.64635 10.85977 11.11981 11.43983 11.83773 12.33773 12.97286 13.69767 14.48432 15.3150411  11.00000 11.08333 11.17949 11.29121 11.42198 11.57624 11.75970 11.97976 12.24612 12.57151 12.97286 13.47286 14.10212 14.81896 15.5972412  12.00000 12.07692 12.16484 12.26593 12.38297 12.51939 12.67959 12.86918 13.09534 13.36743 13.69767 14.10212 14.60212 15.22620 15.9359113  13.00000 13.07143 13.15238 13.24464 13.35042 13.47246 13.61418 13.77993 13.97518 14.20697 14.48432 14.81896 15.22620 15.72620 16.3456914  14.00000 14.06667 14.14167 14.22647 14.32288 14.43309 14.55986 14.70657 14.87751 15.07805 15.31504 15.59724 15.93591 16.34569 16.84569`

12.2451  (Simulation for 10,10
6.53525          and then for 3,6; 10,000 trials each)

DefDbl A-Z
Dim crlf\$
Dim State(14, 14)

Function mform\$(x, t\$)
a\$ = Format\$(x, t\$)
If Len(a\$) < Len(t\$) Then a\$ = Space\$(Len(t\$) - Len(a\$)) & a\$
mform\$ = a\$
End Function

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

For I = 0 To 14: State(I, 0) = I: Next
For I = 0 To 14: State(0, I) = I: Next
For Tot = 2 To 28
For white = 1 To 14
black = Tot - white
If black <= 14 And black >= 0 Then
If black > white Then
If white > 0 Then
State(white, black) = (white / (white + black)) * State(white - 1, black) + (black / (white + black)) * (State(white, black - 1) + 1)
Else
State(white, black) = (black / (white + black)) * (State(white, black - 1) + 1)
End If
Else
If black > 0 Then
State(white, black) = (black / (white + black)) * State(white, black - 1) + (white / (white + black)) * (State(white - 1, black) + 1)
Else
State(white, black) = (white / (white + black)) * (State(white - 1, black) + 1)
End If
End If
End If
Next white
Next Tot
For white = 0 To 14
For black = 0 To 14
Text1.Text = Text1.Text & mform(State(white, black), "##0.00000")
Next
Text1.Text = Text1.Text & crlf
Next

For tr = 1 To 10000

white = 10: black = 10
Randomize Timer

For draw = 1 To 20
r = Int(Rnd(1) * (white + black) + 1)
If r <= white Then
If white > black Then
hits = hits + 1:
ElseIf white = black Then
hits = hits + 0.5
End If
white = white - 1
Else
If black > white Then
hits = hits + 1:
ElseIf white = black Then
hits = hits + 0.5
End If
black = black - 1
End If
Next draw

Next tr

tr = tr - 1
Text1.Text = Text1.Text & hits / tr & crlf

hits = 0
For tr = 1 To 10000

white = 3: black = 6
Randomize Timer

For draw = 1 To 9
r = Int(Rnd(1) * (white + black) + 1)
If r <= white Then
If white > black Then
hits = hits + 1:
ElseIf white = black Then
hits = hits + 0.5
End If
white = white - 1
Else
If black > white Then
hits = hits + 1:
ElseIf white = black Then
hits = hits + 0.5
End If
black = black - 1
End If
Next draw

Next tr

tr = tr - 1
Text1.Text = Text1.Text & hits / tr & crlf

Text1.Text = Text1.Text & crlf & " done"

End Sub

 Posted by Charlie on 2015-07-30 14:56:26

 Search: Search body:
Forums (0)