Post Reply 
little math/programming problems April 2023
04-30-2023, 01:32 AM (This post was last modified: 04-30-2023 01:41 AM by Allen.)
Post: #4
RE: little math/programming problems April 2023
I believe the first few terms are now calculated (hopefully correct). Starting with 5 dice, the chances of the game terminating on exactly x rolls is:

Code:

x  approx                exact  
0  0.0                    0
1  0.13168724279835392   32 / 3^5
2  0.1762589048590848    614576800 / 3^20
3  0.14345296021217352   1477716325360817158616745850400 / 3^65
4  0.11119048831439719   1127935854140837598232937023804660987401971125340384 / 3^109
...

The total number of states for depth grows quickly to [1, 15, 375, 17655, 1469850, , ...] After that things get out of hand Smile

Here's the difference between the Monte Carlo sampling and the exact calculation:

Code:

halting count for 10,000,000 rounds sampling Monte Carlo starting with 5 dice
rolls    count    Monte Carlo    Empirical    Abs Error    Percent error
1    1317393    0.1317393      0.131687243    -5.20572E-05    -0.039530938
2    1761181    0.1761181      0.176258905     0.000140805     0.079885246
3    1434023    0.1434023      0.14345296      5.06602E-05     0.03531486
4    1112492    0.1112492      0.111190488    -5.87117E-05    -0.052802795

10M rolls Total Expected Value 5.4931065

Code:

rolls    count    Monte Carlo    PDF    cumulative
1    1317393    0.1317393    0.1317393    0.1317393
2    1761181    0.1761181    0.3522362    0.4839755
3    1434023    0.1434023    0.4302069    0.9141824
4    1112492    0.1112492    0.4449968    1.3591792
5    862577    0.0862577    0.4312885    1.7904677
6    673073    0.0673073    0.4038438    2.1943115
7    531444    0.0531444    0.3720108    2.5663223
8    424292    0.0424292    0.3394336    2.9057559
9    339510    0.033951    0.305559    3.2113149
10    274634    0.0274634    0.274634    3.4859489
11    223553    0.0223553    0.2459083    3.7318572
12    183459    0.0183459    0.2201508    3.952008
13    149193    0.0149193    0.1939509    4.1459589
14    123336    0.0123336    0.1726704    4.3186293
15    100750    0.010075    0.151125    4.4697543
16    83419    0.0083419    0.1334704    4.6032247
17    68726    0.0068726    0.1168342    4.7200589
18    57454    0.0057454    0.1034172    4.8234761
19    47370    0.004737    0.090003    4.9134791
20    39204    0.0039204    0.078408    4.9918871
21    32289    0.0032289    0.0678069    5.059694
22    26840    0.002684    0.059048    5.118742
23    22160    0.002216    0.050968    5.16971
24    18664    0.0018664    0.0447936    5.2145036
25    15493    0.0015493    0.0387325    5.2532361
26    12861    0.0012861    0.0334386    5.2866747
27    10782    0.0010782    0.0291114    5.3157861
28    9111    0.0009111    0.0255108    5.3412969
29    7672    0.0007672    0.0222488    5.3635457
30    6240    0.000624    0.01872    5.3822657
31    5192    0.0005192    0.0160952    5.3983609
32    4240    0.000424    0.013568    5.4119289
33    3544    0.0003544    0.0116952    5.4236241
34    2980    0.000298    0.010132    5.4337561
35    2461    0.0002461    0.0086135    5.4423696
36    2093    0.0002093    0.0075348    5.4499044
37    1686    0.0001686    0.0062382    5.4561426
38    1459    0.0001459    0.0055442    5.4616868
39    1204    0.0001204    0.0046956    5.4663824
40    1034    0.0001034    0.004136    5.4705184
41    809    0.0000809    0.0033169    5.4738353
42    715    0.0000715    0.003003    5.4768383
43    565    0.0000565    0.0024295    5.4792678
44    448    0.0000448    0.0019712    5.481239
45    396    0.0000396    0.001782    5.483021
46    326    0.0000326    0.0014996    5.4845206
47    311    0.0000311    0.0014617    5.4859823
48    235    0.0000235    0.001128    5.4871103
49    172    0.0000172    0.0008428    5.4879531
50    142    0.0000142    0.00071    5.4886631
51    135    0.0000135    0.0006885    5.4893516
52    102    0.0000102    0.0005304    5.489882
53    73    0.0000073    0.0003869    5.4902689
54    78    0.0000078    0.0004212    5.4906901
55    74    0.0000074    0.000407    5.4910971
56    58    0.0000058    0.0003248    5.4914219
57    45    0.0000045    0.0002565    5.4916784
58    40    0.000004    0.000232    5.4919104
59    34    0.0000034    0.0002006    5.492111
60    22    0.0000022    0.000132    5.492243
61    22    0.0000022    0.0001342    5.4923772
62    20    0.000002    0.000124    5.4925012
63    21    0.0000021    0.0001323    5.4926335
64    16    0.0000016    0.0001024    5.4927359
65    5    0.0000005    0.0000325    5.4927684
66    9    0.0000009    0.0000594    5.4928278
67    5    0.0000005    0.0000335    5.4928613
68    6    0.0000006    0.0000408    5.4929021
69    4    0.0000004    0.0000276    5.4929297
70    3    0.0000003    0.000021    5.4929507
71    5    0.0000005    0.0000355    5.4929862
72    2    0.0000002    0.0000144    5.4930006
73    2    0.0000002    0.0000146    5.4930152
74    5    0.0000005    0.000037    5.4930522
76    2    0.0000002    0.0000152    5.4930674
77    2    0.0000002    0.0000154    5.4930828
78    2    0.0000002    0.0000156    5.4930984
81    1    0.0000001    0.0000081    5.4931065

17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b

Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: little math/programming problems April 2023 - Allen - 04-30-2023 01:32 AM



User(s) browsing this thread: 9 Guest(s)