I got the numbers

[ Follow Ups ] [ Post Followup ] [ Main Message Board ] [ FAQ ]

Posted by Brad Paul on October 20, 2002 at 21:59:29:

In Reply to: probability posted by Alison on October 20, 2002 at 10:12:08:

: In a throw of 12 dice,what is the probability of obtaining a sum of 35 ?

I have the results for this die question.

I ran a Las Vegas simulation to calculate the probabilities. (Just
like a Monte Carlo except with less class and a lot more show, very
American.) Notice that the sum of 42 which is (72+12)/2, has the
largest probability and the other probabilities are symmetrical about
the center. This is what we should expect. If I was hard core I would
run a chi-square test on my simulation to see if my computer die are
really random with a uniform distribution. But as you can see in the
last table where I have kept track of the probability each number
shows up on the die. That the computer die are reasonable. (One would
expect 1/6 for each one which is very close to what I got for each
number.)

I would still be interested in an analytical solution to this question.

The results are shown in the following table:

Total number of rolls of the 12 dice 108235038
Sum Probability Cumulative Probability
12 0 0
13 0 0
14 5.54349137845732e-08 5.54349137845732e-08
15 2.12500502840864e-07 2.67935416625437e-07
16 7.76088792984024e-07 1.04402420960946e-06
17 2.11576587611121e-06 3.15979008572067e-06
18 6.0516447548159e-06 9.21143484053657e-06
19 1.45886214776402e-05 2.38000563181767e-05
20 3.45267121354916e-05 5.83267684536684e-05
21 7.60105059509472e-05 0.000134337274404616
22 0.000154801996743421 0.000289139271148036
23 0.00029807353141965 0.000587212802567686
24 0.000555088270029526 0.00114230107259721
25 0.000974582740941986 0.0021168838135392
26 0.00163790768013589 0.00375479149367509
27 0.00263857254801352 0.00639336404168861
28 0.00408692977961536 0.010480293821304
29 0.00610432640121584 0.0165846202225198
30 0.00881790238757989 0.0254025226100997
31 0.0122756920915018 0.0376782147016015
32 0.0166234616187782 0.0543016763203797
33 0.0217256541269011 0.0760273304472809
34 0.0275950935592594 0.10362242400654
35 0.0339869054233621 0.137609329429902
36 0.0406739728774336 0.178283302307336
37 0.0473703164404118 0.225653618747748
38 0.0535150548937766 0.279168673641524
39 0.0588598952586869 0.338028568900211
40 0.0630207844524432 0.401049353352655
41 0.0656674227804124 0.466716776133067
42 0.0665457335544152 0.533262509687482
43 0.0656679216946364 0.598930431382119
44 0.0630292567550999 0.661959688137219
45 0.0589140828869114 0.72087377102413
46 0.0535158402217219 0.774389611245852
47 0.0473318723277022 0.821721483573554
48 0.0407085088287214 0.862429992402275
49 0.0339778972498721 0.896407889652148
50 0.0275763473192479 0.923984236971396
51 0.0217144839917735 0.945698720963169
52 0.0166198583493822 0.962318579312551
53 0.0122932649591715 0.974611844271723
54 0.00882093282953345 0.983432777101256
55 0.0061156166453233 0.98954839374658
56 0.0040838993376618 0.993632293084241
57 0.00263332470950858 0.99626561779375
58 0.00162844678818332 0.997894064581933
59 0.000972235996258439 0.998866300578192
60 0.000549498582889581 0.999415799161081
61 0.000298489293273034 0.999714288454354
62 0.000154506343869903 0.999868794798224
63 7.34143041553697e-05 0.99994220910238
64 3.45451904400865e-05 0.99997675429282
65 1.43576426702044e-05 0.99999111193549
66 6.01468814562619e-06 0.999997126623636
67 2.04185265773178e-06 0.999999168476293
68 6.19023203927734e-07 0.999999787499497
69 1.75543893651148e-07 0.999999963043391
70 3.69566091897154e-08 1
71 0 1
72 0 1

Sum of the probabilities is 1

Probabilities of each number on the die.
Sum Probability Cumulative Probability
1 0.166671991498107 0.166671991498107
2 0.166661214026952 0.33333320552506
3 0.166670109020827 0.500003314545887
4 0.166672946210511 0.666676260756398
5 0.166660117647547 0.833336378403945
6 0.166663621596055 1

Sum of the probabilities is 1

The Perl script I used is as follows:
#!/usr/bin/perl

#number of die to roll
\$ndie=12;
#After \$count rolls print out results
\$count=1000;

# arrays to keep track of rolls
@dieroll=();

#Yes this is just 5*\$ndie I left it long to help with explanation.
\$dieroll[6*\$ndie-\$ndie]=0;
#Arrays start with a 0 index. I do this so I will print out
#all sums up to 72 even if it is never rolled.
@sums=();
\$j=0;
#n is the number of trials
\$n=0;
#loop forever
while(1){
\$sum=0;
#roll \$ndie die
for(\$i=1;\$i<=\$ndie;\$i++){
\$val=int(6*rand()+1);
#keep track of how often each number on the die is seen.
#This is necessary to make sure that I have good random numbers.
\$sums[\$val-1]=\$sums[\$val-1]+1;
\$sum=\$sum+\$val;
}
#Keep track of how often each sum is rolled
\$dieroll[\$sum-\$ndie]=\$dieroll[\$sum-\$ndie]+1;
\$n++;
if(\$j++>\$count){
\$j=0;
write_stats();
}
}

###########################################################################
# sub to write out results every so often.
sub write_stats
{
open(TMP,">\$ENV{HOME}/die.dat");
my \$i=\$ndie;
\$psum=0;
print TMP "\n";
print TMP "\n";
print TMP "\n";
foreach \$roll (@dieroll){
\$p=\$roll/\$n;
\$psum=\$psum+\$p;
print TMP "\n";
\$i++;
}
print TMP "
Total number of rolls of the \$ndie dice \$n
Sum Probability Cumulative Probability
\$i \$p \$psum

\n";
print TMP "Sum of the probabilities is \$psum\n\n";
print TMP "\n";
print TMP "\n";
print TMP "\n";
\$i=1;
\$psum=0;
foreach \$roll (@sums){
\$p=\$roll/(\$ndie*\$n);
\$psum=\$psum+\$p;
print TMP "\n";
\$i++;
}
print TMP "
Probabilities of each number on the die.
Sum Probability Cumulative Probability
\$i \$p \$psum

\n";
print TMP "Sum of the probabilities is \$psum\n";
close(TMP);
}

Name:
E-Mail:

Subject: