Re: Challenge: Open-ended Dice on the HP-41 Message #2 Posted by hugh steers on 6 Sept 2009, 3:29 p.m., in response to message #1 by Geir Isene
i was interested in how far out from [1,6] the "openness" might get. So i hacked up a quick program in Lua to print out a histogram.
here's what i get after a million goes:
the first column is the value and the second the percentage of trials hitting that value.
1 8.2905
2 16.6888
3 16.6197
4 16.6964
5 16.7057
6 8.3628
7 4.1587
8 2.0964
9 1.0276
10 0.5105
11 0.264
12 0.1336
13 0.0652
14 0.0334
15 0.0141
16 0.0092
17 0.0041
18 0.0024
19 0.0011
20 0.0003
21 0.0002
22 0.0001
23 0.0002
-1 2.0857
0 4.1388
-2 1.0439
-3 0.5196
-4 0.2631
-5 0.1331
-6 0.0665
-7 0.0324
-8 0.0163
-9 0.0072
-10 0.0041
-11 0.0015
-12 0.0013
-13 0.0008
-14 0.0005
-15 0.0001
-16 0.0001
total 100
critical = 2.7771
fumble = 2.7606
So we have a [2,4] plateau (1/6 as expected), then 50% falloff each side. However, it's interesting to note that the "critical" and "fumble" percentages are almost 1 in 36.
This indicates that you don't really get much difference tracking consecutive 1's and 6's after the first go. Consequently, i modified my simulator to count a "critical" as 2 6's at the start and a "fumble" as 2 1's. here's what i get:
1 8.2841
2 16.659
3 16.6423
4 16.7312
5 16.7244
6 8.2914
7 4.2017
8 2.0684
9 1.0386
10 0.5212
11 0.2641
12 0.1315
13 0.0618
14 0.0322
15 0.0185
16 0.0073
17 0.0041
18 0.002
19 0.0012
20 0.0006
22 0.0001
23 0.0001
24 0.0001
-7 0.0298
-8 0.0176
-9 0.0072
-10 0.0033
-11 0.0024
-12 0.0006
-13 0.0006
-14 0.0003
-1 2.0799
0 4.1518
-2 1.0266
-3 0.5313
-4 0.2638
-5 0.1286
-6 0.0701
-15 0.0002
total 100
critical = 2.7716
fumble = 2.7501
Similar story. So i would say, for the purposes of generating values for Amar, you could simplify your algorithm on the 41c and not track consecutive values. which should shorten the program.
here are my two versions. o6() is the "real" algorithm and "os6plain" is my hacked one.
function d6()
return math.floor(math.random()*6+1)
end
function o6()
local v = d6()
local d
local crit = false
local fumb = false
local c = true
if v == 6 then
while true do
d = d6()
if d >= 4 then
v = v + 1
if d == 6 then
crit = c
c = true
else
c = false
end
else break
end
end
elseif v == 1 then
while true do
d = d6()
if d < 4 then
v = v - 1
if d == 1 then
fumb = c
c = true
else
c = false
end
else break
end
end
end
return v,crit,fumb
end
function o6plain()
local v = d6()
local crit = false
local fumb = false
if v == 6 then
crit = d6() == 6
while d6() >= 4 do v = v + 1 end
elseif v == 1 then
fumb = d6() == 1
while d6() < 4 do v = v - 1 end
end
return v,crit,fumb
end
|