We roll five standard dice (sides numbered 1 to 6) and write down the sum of the top three i.e. of the 3 highest values.
What is the probability to get 15 ?
The following program examines each possible combination of numbers of the various numbers of pips, using each one's probability to add to the corresponding total's probability of occurring:
100 Ndice=5:Ntop=3
110 Remaining=Ndice:CurrProb=1
120 dim TProb(Ndice*6)
130 dim Hist(6)
140
150 gosub *SetQuant(6)
160 for I=1 to Ndice*6
170 CProb=CProb+TProb(I)
180 print I,TProb(I),CProb/1,1-CProb/1
190 next I
200
210 end
220
1100 *SetQuant(Den)
1110 local Nbr,P,Strt
1120 if Den=1 then Strt=Remaining:else Strt=0
1130 for Nbr=Strt to Remaining
1135 if Den=1 then
1136 :P=1
1137 :else
1140 :P=(1//Den)^Nbr*((Den-1)//Den)^(Remaining-Nbr)*combi(Remaining,Nbr)
1150
1160 CurrProb=CurrProb*P
1170 Remaining=Remaining-Nbr
1180 Hist(Den)=Nbr
1190
1200 if Remaining=0 then
1210 :gosub *CountIt(Den)
1220 :else
1230 :gosub *SetQuant(Den-1)
1240
1250 Remaining=Remaining+Nbr
1260 CurrProb=CurrProb//P
1270 next Nbr
1280 return
1290
2100 *CountIt(D)
2110 local Pips,Totv,Totn
2120 for Pips=6 to D step -1
2130 if Hist(Pips)>=Ntop-Totn then
2140 :Totv=Totv+Pips*(Ntop-Totn)
2150 :Totn=Ntop
2160 :else
2170 :Totv=Totv+Pips*Hist(Pips)
2180 :Totn=Totn+Hist(Pips)
2190 next Pips
2200 TProb(Totv)=TProb(Totv)+CurrProb
2210 return
The result is a display that shows all the possible totals:
score p(score) p(<= this score) p(> this score)
1 0 0 1
2 0 0 1
3 1/7776 0.0001286008230452674 0.9998713991769547325
4 5/7776 0.0007716049382716048 0.9992283950617283951
5 5/2592 0.0027006172839506172 0.9972993827160493827
6 41/7776 0.0079732510288065843 0.9920267489711934156
7 5/432 0.0195473251028806584 0.9804526748971193415
8 85/3888 0.0414094650205761316 0.9585905349794238683
9 37/972 0.0794753086419753086 0.9205246913580246913
10 235/3888 0.1399176954732510287 0.8600823045267489712
11 665/7776 0.2254372427983539094 0.7745627572016460905
12 881/7776 0.3387345679012345678 0.6612654320987654321
13 1055/7776 0.4744084362139917695 0.5255915637860082304
14 385/2592 0.6229423868312757201 0.3770576131687242798
15 1111/7776 0.7658179012345679012 0.2341820987654320987
16 935/7776 0.886059670781893004 0.1139403292181069959
17 305/3888 0.9645061728395061728 0.0354938271604938271
18 23/648 1.0 0
19 0 1.0 0
20 0 1.0 0
21 0 1.0 0
22 0 1.0 0
23 0 1.0 0
24 0 1.0 0
25 0 1.0 0
26 0 1.0 0
27 0 1.0 0
28 0 1.0 0
29 0 1.0 0
30 0 1.0 0
So the probability of a score of exactly 15 is 1111/7776 ~= .1428755144032922. The probability of getting at least 15 is the same as the probability of getting > 14, which is shown above as being approximately 0.3770576131687242798. Adding the individual probabilities for 15 through 18 gives this as exactly 733/1944.
As all the denominators can be expanded to 6^5 = 7776, the following table can be made by a slight modification of the program, in which the last two columns have been multiplied by 7776, so as to provide the numerators for a fraction with that number in the denominator:
value p(score=value) p(score<=value) p(score > value)
-------numerators only -------
2 0 0 7776
3 1/7776 1 7775
4 5/7776 6 7770
5 5/2592 21 7755
6 41/7776 62 7714
7 5/432 152 7624
8 85/3888 322 7454
9 37/972 618 7158
10 235/3888 1088 6688
11 665/7776 1753 6023
12 881/7776 2634 5142
13 1055/7776 3689 4087
14 385/2592 4844 2932
15 1111/7776 5955 1821
16 935/7776 6890 886
17 305/3888 7500 276
18 23/648 7776 0
As the specific interest in this problem is for a score of 15, the following details the derivation of probability 1111/7776 for that score. The sets of showing numbers of pips are all those that score 15. The first probability, for example, is 5/3888 = 10/7776, as 3 5's and two 1's can occur in C(5,3) = C(5,2) = 10 ways.
number of
6's 5's 4's 3's 2's 1's probability
0 3 0 0 0 2 5/3888
0 3 0 0 1 1 5/1944
0 3 0 0 2 5/3888
0 3 0 1 0 1 5/1944
0 3 0 1 1 5/1944
0 3 0 2 5/3888
0 3 1 0 0 1 5/1944
0 3 1 0 1 5/1944
0 3 1 1 5/1944
0 3 2 5/3888
0 4 0 0 0 1 5/7776
0 4 0 0 1 5/7776
0 4 0 1 5/7776
0 4 1 5/7776
0 5 1/7776
1 1 1 0 0 2 5/648
1 1 1 0 1 1 5/324
1 1 1 0 2 5/648
1 1 1 1 0 1 5/324
1 1 1 1 1 5/324
1 1 1 2 5/648
1 1 2 0 0 1 5/648
1 1 2 0 1 5/648
1 1 2 1 5/648
1 1 3 5/1944
2 0 0 1 0 2 5/1296
2 0 0 1 1 1 5/648
2 0 0 1 2 5/1296
2 0 0 2 0 1 5/1296
2 0 0 2 1 5/1296
2 0 0 3 5/3888
which do indeed add up to 1111/7776.
Simulation verification:
DEFDBL A-Z
CLS
DIM valCt(20)
FOR trial = 1 TO 1000000
tot = 0
FOR die = 1 TO 5
pips(die) = INT(RND(1) * 6) + 1
NEXT die
DO
done = 1
FOR i = 1 TO 4
IF pips(i) < pips(i + 1) THEN SWAP pips(i), pips(i + 1): done = 0
NEXT
LOOP UNTIL done = 1
FOR i = 1 TO 3
tot = tot + pips(i)
NEXT
valCt(tot) = valCt(tot) + 1
NEXT trial
FOR i = 3 TO 18
c = c + valCt(i) / (trial - 1)
PRINT USING "## #.####### #.#######"; i; valCt(i) / (trial - 1); c
NEXT
goes through a million trials and gets the following statistics:
val fraction =val fraction <= val
3 0.000142 0.000142
4 0.000625 0.000767
5 0.001896 0.002663
6 0.005248 0.007911
7 0.011541 0.019452
8 0.021726 0.041178
9 0.038271 0.079449
10 0.060519 0.139968
11 0.085300 0.225268
12 0.113187 0.338455
13 0.135842 0.474297
14 0.148759 0.623056
15 0.142818 0.765874
16 0.120569 0.886443
17 0.077907 0.964350
18 0.035650 1.000000
|
Posted by Charlie
on 2010-11-15 18:33:10 |