View Single Post
  #10  
Old May 11th, 2008, 11:19 AM
lch's Avatar

lch lch is offline
General
 
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
lch is on a distinguished road
Default Re: Maths problem: fatigue vs critical hits

Quote:
lch said:
Now with two dice, I'm not sure but I think it goes like this: You want a combination of two rolls that add up to X, so X = Y+(X-Y) and 0 < Y < X. Your probability is given as follows: For every Y from 1 to X-1, multiply P(Y) and P(X-Y) as given above. Add all of them together, divide by X-1. That's your probability for two rolls. You can simplify it into a closed form, which could be kinda tricky because of the modulo representation for Y and X-Y. Maple helps.
Okay, the second part was pretty bogus. It shows that I never really learned probability calculus. Another try:

X = 6a + b, 0 <= b < 6. Then the probability that a DRN gives X or higher on a roll is P(">= X") = (7-b)(1/6)^(a+1).
The probability that it equals X is P("= X") = (1/6)^(a+1).

But measuring a two-die roll isn't as easy. Here's a small python program that I used to check cleveland's calculations:

Code:
#!/usr/bin/env python

def p_1(x):
if x < 1:
return 1
b = x % 6
a = (x-b)/6
return (7-b)*pow((float(1)/6), a+1)

def p_2(x):
if x < 1:
return 0
b = x % 6
a = (x-b)/6
return pow((float(1)/6), a+1)

def doubledrn(x):
M = [(a,b) for a in range(1,x-1) for b in range(1,x-a)]
s = 0.0
for (x_1, x_2) in M:
s += p_2(x_1)*p_2(x_2)
return 1-s

def doubledrn_2(x):
s = p_1(x)
for y in range(1,x-1):
s += p_2(y)*p_1(x-y)
return s

for x in range(2,18):
print ">= %2d : %f" % (x, doubledrn(x))


And here's the output of it: Code:
>=  2 : 1.000000
>= 3 : 0.972222
>= 4 : 0.916667
>= 5 : 0.833333
>= 6 : 0.722222
>= 7 : 0.583333
>= 8 : 0.462963
>= 9 : 0.361111
>= 10 : 0.277778
>= 11 : 0.212963
>= 12 : 0.166667
>= 13 : 0.119599
>= 14 : 0.079475
>= 15 : 0.046296
>= 16 : 0.020062
>= 17 : 0.000772


So as far as I can tell, cleveland's table is right. The difference in later numbers probably comes from rounding precision being a ***** again, as my code probably isn't numerically stable. If I'd calculate greater values, the numbers even turn negative! I'd be interested what formulas cleveland used to be able to trick the rounding precision.
__________________
Come to the Dom3 Wiki and help us to build the biggest Dominions-centered knowledge base on the net.
Visit my personal user page there, too!
Pretender file password recovery
Emergency comic relief
Reply With Quote