There are 9900 ways the two players could pick their tiles.
The number of ways a particular number can contribute to the overall probability of getting two of the same letter is the count of how many there are of that letter times one less. The count table in the program below also has the number of letters that have that particular count, for example only one letter has 12 tiles with that letter on it; that accounts for the first line having entries of 12 (the count of that individual letter) and 1 (how many letters of the alphabet have that count of tiles).
Putting it into the succinct form from Jer's comment, it's
(12*11+9*8*2+8*7+6*5*3+4*3*4+3*2+2*1*10+1*0*5)/9900
with the 10 in 2*1*10 being the ten tiles that are duplicated, including the blank tiles.
The result comes out to
496/9900 = 124/2475 ~= 0.05010101010101
ct(1, 0) = 12: ct(1, 1) = 1
ct(2, 0) = 9: ct(2, 1) = 2
ct(3, 0) = 8: ct(3, 1) = 1
ct(4, 0) = 6: ct(4, 1) = 3
ct(5, 0) = 4: ct(5, 1) = 4
ct(6, 0) = 3: ct(6, 1) = 1
ct(7, 0) = 2: ct(7, 1) = 10
ct(8, 0) = 1: ct(8, 1) = 5
For i = 1 To 8
tot = tot + ct(i, 0) * ct(i, 1)
Next
Text1.Text = Text1.Text & tot & crlf & crlf
For i = 1 To 8
ways = ways + ct(i, 1) * ct(i, 0) * (ct(i, 0) - 1)
Next
Text1.Text = Text1.Text & ways & "/" & "9900 = " & Format(ways / 9900, "0.00000000")
For the bonus question the calculation becomes harder, as we need calculate not only whether some pair of players has a match, but whether that match is of the letter is the one that is closest to A (or blank). For example JCJ does not count as a tie as C is uniquely the winner, while CJC is a tie as the best scoring letter occurs twice.
As an example of the calculations, consider the case of 4 players, and in particular the contribution to the probability of a matching pair from the letter C.
There are 13 tiles lower (better) than C, including the two blank tiles. The probability that there are none of these tiles present is (87/100)*(86/99)*(85/98)*(84/97). There are 2 C tiles, so there are 15 tiles lower than D and the probability that none of these are chosen is (85/100)*(84/99)*(83/98)*(82/99). Subtracting the latter product from the former gives the probability that at least one C is present but nothing lower.
The probability of having exactly one C given nothing lower than C is present is 4*(2/87)*(85/86)*(84/85)*(83/84). The factor of 4 is the fact any of the 4 players could have chosen the sole C. This is subtracted from the probability having any C's given there's none under C, to get the conditional probability there's more than one C. Then that's multiplied by the probability that in fact there is nothing lower than C.
The program below calculates the probability first that for any given letter or blank, that no other letter has a letter closer to A or blank than itself, and then the probability, given that condition, that it will occur, and that it will not be unique. The overall probability of that happening is then added to the total for all the letters, and blank, that could be duplicated.
5 open "scrblstr.txt" for output as #2
10 dim tiles(26),before(27)
20 tiles(0)=2
30 tiles(1)=9
40 tiles(2)=2
50 tiles(3)=2
60 tiles(4)=4
70 tiles(5)=12
80 tiles(6)=2
90 tiles(7)=3
100 tiles(8)=2
110 tiles(9)=9
120 tiles(10)=1
130 tiles(11)=1
140 tiles(12)=4
150 tiles(13)=2
160 tiles(14)=6
170 tiles(15)=8
180 tiles(16)=2
190 tiles(17)=1
200 tiles(18)=6
210 tiles(19)=4
220 tiles(20)=6
230 tiles(21)=4
240 tiles(22)=2
250 tiles(23)=2
260 tiles(24)=1
270 tiles(25)=2
280 tiles(26)=1
290
300 for i=1 to 26
310 before(i)=before(i-1)+tiles(i-1)
320 next
321 before(27)=100
330 print before(26)+tiles(26)
340
350 for noPlayers=2 to 8
351 totProb=0
360 for ltr=0 to 26
370 probOnly=1
380 numr=100-before(ltr):deno=100
390 p=1
400 repeat
410 probOnly=probOnly*numr//deno
420 dec numr:dec deno
430 inc p
440 until p>noPlayers or numr<0
450 probNotHave=1 ' given that only this and above occur
460 numr=100-before(ltr+1):deno=100-before(ltr)
470 p=1
480 repeat
490 probNotHave=probNotHave*numr//deno
500 dec numr:dec deno
510 inc p
520 until p>noPlayers or deno=0 or numr<0
530 probHave=1-probNotHave ' given that only this and above occur
531 'if ltr<16 then print ltr,probHave/1
540 if probHave>0 and ltr<26 then
543 :probHave1= tiles(ltr)//(100-before(ltr))
545 :p=2
547 :numr=100-before(ltr+1):deno=99-before(ltr)
549 :repeat
551 :probHave1=probHave1*numr//deno
553 :dec numr:dec deno
555 :inc p
557 :until p>noPlayers or deno=0 or numr<0
559 :probHave1=probHave1*noPlayers
560 :probHave1plus=probHave-probHave1
570 :totProb=totProb+probOnly*probHave1plus
580 :endif
590 next ltr
600 print noPlayers,totProb,totProb/1
605 print #2,noPlayers,totProb,totProb/1
610 next noPlayers
620 close #2
The results are:
2 124/2475 0.0501010101010101009
3 25/294 0.0850340136054421768
4 456503/3921225 0.1164184661680979795
5 3654367/25095840 0.1456164447972253568
6 205978427/1192052400 0.1727930978537520665
7 1585995557/8003780400 0.1981558060988279988
8 187764172/845854065 0.2219817575742217423
A simulation of ten million trials shows agreement with this:
players probability
2 501443/10000000 = 0.0501443
3 849717/10000000 = 0.0849717
4 1166902/10000000 = 0.1166902
5 1455121/10000000 = 0.1455121
6 1726306/10000000 = 0.1726306
7 1980379/10000000 = 0.1980379
8 2216635/10000000 = 0.2216635
DefDbl A-Z
Dim crlf$, age(4), digits$, ties(10), used()
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
s0$ = "EEEEEEEEEEEEAAAAAAAAAIIIIIIIIIOOOOOOOONNNNNNRRRRRRTTTTTTDDDDLLLLSSSSUUUU"
s0$ = s0$ + "GGGBBCCFFHHMMPPVVWWYYJKQXZ "
Text1.Text = Text1.Text & Len(s0) & crlf & crlf
For rpt = 1 To 100
Randomize Timer
For tr = 1 To 100000
s$ = s0$
lowest = 999
ReDim used(32 To 96)
For player = 1 To 8
DoEvents
r = 1 + Int(Rnd(1) * Len(s))
v = Asc(Mid(s, r, 1))
s = Left(s, r - 1) + Mid(s, r + 1)
If v < lowest Then lowest = v
used(v) = used(v) + 1
If player > 1 Then
If used(lowest) > 1 Then ties(player) = ties(player) + 1
End If
Next
trials = trials + 1
Next tr
Next rpt
For i = 2 To 8
Text1.Text = Text1.Text & i & " " & ties(i) & "/" & trials & " = " & ties(i) / trials & crlf
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
|