Help - Search - Members - Calendar
Full Version: Open Test...
Dumpshock Forums > Discussion > Shadowrun
Gorath
Hi,

Sometime ago we had a discussion about open rolls (like a stealth test) here on the dumpshock boards.

We developed a formula to calculate the expected value at an open roll.

I.e. for 1 die the expected value is E(1)=4.2
You get this from:
E(1)=1/6 + 2/6 + 3/6 + 4/6 + 5/6 + 1/6*(E(1)+6) ==> E(1)=21/5=4.2

You can continue this, if E(2) is the expected value rolling 2 dice you get:

E(2)= 1/36*(E(2)+6)+ 10/36*(E(1)+6)+1/36*95 ==> E(2)=29/5=5.8

If you rewrite using Binomial factors you get:

E(2) = B(2,2) * (1/6)^2 * (5/6)^0 * (E(2)+6) + B(2,1) * (1/6)^1 * (5/6)^1 * (E(1)+6) + (1/6)^2 * R(2)

with R(x):= (Sum from k=1 to 5) (k^x-(k-1)^x)*k


==>

E(x):=B(x,x)*(1/6)^x * (5/6)^0 * (E(x)+6) + B(x, x-1) * (1/6)^(x-1) * (5/6)^1 * (E(x-1)+6) + B(x, x-2) * (1/6)^(x-2) * (5/6)^2 * (E(x-2)+6) + ... +B(x,2) * (1/6)^2 * (5/6)^(x-2) * (E(2)+6) + B(x,1) * (1/6)^1 * (5/6)^(x-1) * (E(1)+6) + (1/6)^x * R(x)

My question is:

(a) Can someone remember this discussion and has a link to the post?

(b) Is anyone good in math and can give a expicite formula (insteed of this recursive one) to calculate E(x)?
Gorath
*deleted*
Fonitrus
QUOTE (Gorath)
*deleted*

da scroll, da scroll, da button, da button, scrolling so smooth like the butter on the muffin smile.gif

go strongbad...
Gorath
*bump*
Zazen
I remember starting that thread. I think its topic was "arithmetic mean of a shadowrun d6". If I remembered the URL to the old boards, I'd go find it.
Reaver
QUOTE (Zazen)
I remember starting that thread. I think its topic was "arithmetic mean of a shadowrun d6". If I remembered the URL to the old boards, I'd go find it.

I'd be inclined to help out, but I'm not an Algebra Shaman. wink.gif
Jason Farlander
QUOTE (Fonitrus)
QUOTE (Gorath @ Feb 2 2004, 04:59 AM)
*deleted*

da scroll, da scroll, da button, da button, scrolling so smooth like the butter on the muffin smile.gif

go strongbad...

I keep the buttons on scroll and all the ladies in check; did you find the spare keys to my apartment yet? Word.

oh... and heres the thread.

(I'm decently good at math, but I'm not in a mathy mood right now. Maybe later.)
Daishi
E(1) = 4.2, E(2) = 5.8, E(3) = 6.85116
E(4) = 7.64789, E(5) = 8.29710, E(6) = 8.84773
E(7) = 9.32640, E(cool.gif = 9.74950, E(9) = 10.1281
E(10) = 10.4700, E(11) = 10.7811, E(12) = 11.0662
E(13) = 11.3288, E(14) = 11.5719, E(15) = 11.7981
E(16) = 12.0093, E(17) = 12.2074, E(18) = 12.3938
E(19) = 12.5698, E(20) = 12.7365, E(21) = 12.8948
E(22) = 13.0455, E(23) = 13.1893, E(24) = 13.3270

I believe that's the pertinent part stolen from what I read from the thread Jason dug up. I'd confirm it, but I'm still trying to figure how to avoid the infinite series. I'm not good at those.
Gorath
Thanks! I did not remeber the thread and i find searching the old board a real pain...

But for all mathematical interessted: YOU MUST READ THE OLD DISCUSSION. And there are still problems to solve (i.e. "What Stealth skill is needed to beat a Perception Test with 50%, 70%, 95%?")
The White Dwarf
Calculating the specific percentile chances for success is easy if you simply provide the dice amounts and TNs of the equation, its simple algebra.

If youre trying to come up with a formula for an open test thats more difficult.

Simply put, if you are dealing with intelligence 6, presume they will get a single 6 at least 2/3rds of the time, which will then be a 10+ 1/3rd of the time. In otherwords intelligence 6 = 10+ on 1 in 3 rolls most of the time.

So to beat intelligence 6 npcs with an open stealth roll most of the time, you would need to be scoring 10+ over half the time, which would happen somewhere near 12 dice thrown.

Those are rough averages, which you could bank on as a gauge of you odds for success. Thing is, those odds are *most of the time* as in about 66% in your favor. If you want your margin of error to be closer to like failing 5% of the time you would need a lot of dice... At that point its best to go for something like Traceless Walk or Camoflauge... only when you run the math does the huge benefit of such things become really apparent.

Bottom line: improve dice for stealth up to 10ish if possible, because combined with camo or other bonuses you can beat most things most of the time.
Rev
An unmodified stealth roll like that would be something like sneaking around a 1/3 full parking lot in the middle of a clear day. Some cover, but no other modifiers.

A full parking lot should probably get some unusually good cover modifier, darkness or rain would bring visibility modifiers, distractions further modifiers, etc, etc.
gknoy
QUOTE (Gorath)
(b) Is anyone good in math and can give a explicit formula (instead of this recursive one) to calculate E(x)?

Often, a recursive definition is Simpler and More Elegant. Usually, if someone chooses to express it recursively, it is because it's simplerthat way. In this case [and having not read the Old Thread, so I can be wrong smile.gif], I expect that there might not _be_ a simple Plug In The Numbers Here type equation.

Besides, it might not be that bad to write a program to calculate it.
If I can find out how to express B(a, b), (since I've had trouble digging that up online) I might be able to write code for it ...

Remember, just because we don't like equations that are super-super-extremely-long, doesn't mean that Perl might not. ;-D (When in doubt, use the big hammer. You'd be surprised how well it can work. [yes, I'm stealing and badly paraphrasign Donald Knuth. smile.gif])

heck, if I were crazy [and I might be wink.gif], I might start working on implementing that ... smile.gif


On a side note - How can I access the Old Forums? I thought there was a link on the main forums page but I can't seem to find it.
Zazen
It appears that the old forums are at http://jive.dumpshock.com/default/. For some reason http://jive.dumpshock.com/ by itself redirects to the new forums.
Gorath
QUOTE (gknoy @ Feb 3 2004, 06:26 AM)

Often, a recursive definition is Simpler and More Elegant.  Usually, if someone chooses to express it recursively, it is because it's simplerthat way.  In this case [and having not read the Old Thread, so I can be wrong smile.gif], I expect that there might not _be_ a simple Plug In The Numbers Here type equation.

Besides, it might not be that bad to write a program to calculate it.
If I can find out how to express B(a, b), (since I've had trouble digging that up online) I might be able to write code for it ...
]



I don't think this recursive definition is more simpler, because you need to know all E(1), E(2),..., E(k) to get a not so simple equation for E(k+1). If you have a explicite formula, you have something like E(k)=f(k) where f is a function.


B(n,k) gives the number of possibile solution to choose k elements out of n given.
B(n,k)=Binomial(n,k) := n! / ((n-k)! k!)
i.e. B(5,3)=5! /(2! * 3!) = 120 / (2 * 6) = 10
Daishi
QUOTE (gknoy)
Often, a recursive definition is Simpler and More Elegant. Usually, if someone chooses to express it recursively, it is because it's simplerthat way...

Besides, it might not be that bad to write a program to calculate it.
If I can find out how to express B(a, b), (since I've had trouble digging that up online) I might be able to write code for it ...

I was going to build a quick little app to handle the calc, but I found a slight flaw in using a recursive algorithm to calculate the open test result: there is no base case! It's an open test. It does not end. There are dirty tricks I could use, but I didn't feel like coding if I couldn't do it right. An elegant solution to an infinite series is beyond my ken, and I'm lacking access to Matlab or Mathematica right now, which are probably my preferred solutions at this point.
The White Dwarf
Yea, it *is* an unlimited situation, which is why I tossed out some solid averages to go off of. And as Rev pointed out, theyre using pretty base numbers which means if youre using camo and some terrain to your advantage (as mentioned) while throwing 10ish dice at the test, youre pretty much good to go, unordinary circumstances aside. Like, dont try to stealth past the sensor 3 drone, m'kay? Or sneak past the thermal vision guards holding a recently fired gun. Etc.
In the end, 10-12 dice and some basic mods + common sense = stealthy runner.
Gorath
How can you define a recursive function in Mathematica?

And how can i define a recursive function (in Mathematica) that depends of all values before?
gknoy
QUOTE (Gorath)
I don't think this recursive definition is more simpler, because you need to know all E(1), E(2),..., E(k) to get a not so simple equation for E(k+1). If you have a explicite formula, you have something like E(k)=f(k) where f is a function.


B(n,k) gives the number of possibile solution to choose k elements out of n given.
B(n,k)=Binomial(n,k) := n! / ((n-k)! k!)
i.e. B(5,3)=5! /(2! * 3!) = 120 / (2 * 6) = 10

THANK you for the B(n,k) formula. =)

The recursive definition does NOT include all previous ones.

Rather, E(x) needs E(x-1) and E(x-2) --- unless I misread the original post.
Yes, you do need to eventually calculate all of the E() 1..k ... that's true. But you can implement it relatively easily.


Regarding it being open, and having no cap: That sounds like it's true... but the definition of E(x) that Gorath originally gave us might account for that. Remember that we aren't really rolling dice, but saying what we *expect* to get. And by expect, I mean have any reasonable probability of happening... recall that the likelihood of rolling high decreases rather fast.
Gorath
You need E(1) ... E(k-1) to calculate E(k)!

I think, if you simulate the open roll, it would be interessting to see the complete propabilities for each outcome.

So you can get:

1. the expected value
2. and know how narrow the distribution is

So for x d6 make 10^12 open rolls and remember the results. Then make a diagramm for the results from 1 to highest roll. So you can see the distribution and the "expected" value. Perhaps someone can write a programm to do this and show us the distributions wink.gif
kenji
blah blah blah deleted.

something like:

E.V. = Limit ( n->infinity; Sigma{ i=1..n; i*P(i) } )
P(i) = 1/6^(floor([i-.5]/6)+1)

---
edit: i apologise for my 1 dimensional waste, as Quujquux has answered the question fully, and algebraically.
gknoy
Gorath - if you are doing the calculations by hand, you should just shoot yourself. wink.gif

If you are doing it with a computer, then don't worry about it -- we aren't recursing far enough to cause any memory issues.

Incidentally - I have tried to implement the recursive definition that Quujquux (sp? did I misplace some letters?) posted in the Old Forum; Unlike yours, it was explicitly recursive...

I got WILDLY different numbers, way different from the ones he posted as his calculated values, and obviously wrong. wink.gif Which confuses me: Either I made a mistake in implementing his forumla (which I doubt, as the formula was relatively simple), or he made a typo in giving it to us. (As for the previous ones he gave us, I don't see how they would work, since the definition for E(x) in his post includes E(x) in its definition; sounds circular.)

The interesting thing is, I KNOW that Quu[etc] was on to something correct. I wrote some brute-force roll-a-bunch-of-dice code (REALLY easy!), and ran it for 100,000 iterations for each number of dice to use in an open test. (So, I did 800,000 open tests). This took about two to three minutes on my old P2 at work, and the numbers I got were VERY close (like, within 0.1) to what Quujquux posted. I was impressed with his math -- expected values don't need 5 digits of precision anyways, but I do love the elegance of an exact answer.

So, now I'm curious - what WAS his original formula, really? (Or did I mis-implement it - doubtful, since it's just a big math expression with a summation inside -- ?)

If anyone's interested, I can post code for this on the web (no, I won't clutter this board unnecessarily smile.gif).
Gorath
Hmm, as far as i see, the last formula that Quu[etc] gave is correct. (He has a small typo in the formula for f(n), but the last result for E(n) is correct...

gknoy
That's what I thought too... (BTW guys, this is going to be a relatively long post. Apologies ahead of time. :))

For reference, a copy of my script can be seen at
http://www.anasazisystems.com/~gknoy/perl_...penTest.pl.html

I used:
CODE
E(n) = 1/(6^n - 1) * (6^(n+1) - 5^n - 4^n - 3^n - 2^n - 1)
        + Sum i=1..n-1 of E(i)*(n choose i)*5^(n-i)

(from The Old Forum)

When I run my code that implements it, though I get
E(1) = 3.5
E(2) = 39.4722222222222
E(3) = 859.541666666667
E(4) = 24866.9112654321
E(5) = 896841.407021605
E(6) = 38814870.7454775
E(7) = 1959930608.26011
E(8) = 113103327463.866
E(9) = 7342812502005.06

.. which leads me to think there's a bug in my code. But I can't find it, as yet. O_o

However, when I run my empirical test (with a bit under a million open tests rolled), I get:
E(1) = 4.20127
E(2) = 5.81023
E(3) = 6.85598
E(4) = 7.65706
E(5) = 8.30353
E(6) = 8.84027
E(7) = 9.30096
E(8) = 9.76566

Further investigation, following the formula by hand, yeilds:

CODE
E(1) = 1/(6-1) * (6^2 - 5 - 4 - 3 - 2 - 1) + sum( 1..0 ) [nothing]
       = 1/5 * (36 - 15) = (21)/5
       = 4.2

E(2) = 1/(6^2 - 1) * (6^3 - 25 - 16 - 9 - 4 - 1) + ( E(1) * (2 choose 1) * 5^1 )
       = 1/35 * (216 - 55) + (4.2 * (2) * 5)
       = 1/35 * (161) + 42


This is what I implemented, and now I see why I was getting crazy numbers: the 42 (and therefore the summation) needs to be inside the term that is multiplied by 1/(6^n - 1).

Looking back at Quujquux's post, I just now noticed that his original description of E(n) has the summation there, and the parenthesis probably just migrated. It should read:

CODE
E(n) = 1/(6^n - 1)
       * ( 6^(n+1) - 5^n - 4^n - 3^n - 2^n - 1
            + Sum i=1..n-1 of E(i)*(n choose i)*5^(n-i) )


Having fixed my program to match, I get numbers that are pretty much what Quujquux posted. In order to have an average open-test roll of 10 or better, you need to be rolling 9 dice. 13's start at 22 dice, 14's at 30 dice, 15s at 41 dice. 16's start being average when you are rolling 55 dice: Good luck on that one. ;)

So, you can expect stealthy starting characters to be rolling probably 9's (or 11s if they're an adept ;)).
Gorath
The interessting point is, how narrow are those expected values?

Sure, mathematical you need a INT9 to beat a Stealth9 guy (with no mods to TNs). BUT sometimes a INT4 guard will roll lucky and get high numbers too. So how is the propability for a Stealth9 runner to sneak past a Int4 guard?

If you work brute force you just need to make a open roll with x d6s versus a open roll with y d6s and check who got the hightes roll. Do this 10^6 times for 0<x,y<24 and post your results wink.gif

The propability to beat guard with INT x with Stealth y is p(x,y).

IF someone is able to write a programm to calculate this, and post the results, i would be very glad biggrin.gif


EDIT: If you got this, you can calculate p(x,y,m) there m is the modifation to the TN of the guard. -24<m<24 rotfl.gif
gknoy
hehe ... smile.gif

The expected values andthe experimentally determined values are almost always within .1 ... which for our use is probably Just Fine.

The distribution of open roll results, now THAT is interesting -- I imagine I'd end up rolling a bunch of times, and having counting-buckets of which results turn up.

I was going to disagree with you on the int X needed to beat stealth-X boy -- but then I realized, the open test probability is the same as a success test that will get at least one success... I think. The mechanics are the same, but the expected value ... would that be the same? I'm curious, but I am pretty sure they're the same.

p(x,y) should be not-that-hard to compute ... find E(y), and then find the probability that x dice will beat E(y). Those should be storeable in a 42x42 array . . . *winks* In fact, p(x,y,m) should simply alter what the indices are to look it up, right?

I'm curious, too ... I wonder what the best method is (perhaps including the simple brute-force method wink.gif) to calculate those probabilities of n dice beating some target? As an aside, I'd consider P(n, t) to represent the probability of beating TN t with n dice. But that could be confusing when paired with your preemptive definition of p(x,y). wink.gif Though, I believe that p(x,y) = 1 - P(x, E(y)), right? Or would it be more complicated?
Prototype
Due to the ridiculous level of variance in the open test I only use them for stress points pretty much, where the numbers getting ludicrous doesn't matter so much.

For stealth tests I have my players roll against base TN4 and add +1 to the Perception test TN for each success. Stops things getting too ludicrous (though 13 stealth dice and centering can really make it tough at times!)
Gorath
Okay, i have some ideas for those propabilities p(x,y) that someone (A) with x dice gets more or equal as someone (B) with y dice.

First i will calculate the probability p(1,1). We can assume that p(1,1)>0.5, because "tie goes to the attack" at stealth versus intelligence.

If x=1, the only success is for y=1.
If x=2, we need y=1,2
...
If x=5, y=1,2,3,4,5 is okay.
If x=6, we have a automatic success, if y is not 6. Else both roll 1d6 again.

==>

p(1,1) = 1/6*1/6 + 1/6*2/6 + 1/6*3/6 + 1/6*4/6 + 1/6*5/6 + 1/6*5/6 + 1/6*1/6*p(1,1)

Simplifing:

p(1,1)=20/36 + 1/36*p(1,1)

Solving for p(1,1):

p(1,1)=36/35*20/36=4/7 > 0.5

as we aspected before.
Gorath
Now i will develop a recursiv solution for p(2,1):

We must distinguish between some cases:

1. A has two 6s, B has no 6:
In this case A wins.

2. A has two 6s, B has one 6:
In this case we have the same situation as before, so p(2,1).

3. A has one 6, B has no 6:
A wins.

4. A has one 6, B has one 6:
We are in the situation p(1,1), because A can only roll 1 die.

5. A and B don't have any 6s:
In this case we must look, who gets teh higher result. The propability that A wins in this case is called R(2,1) and is calculated later...

If we stick all this informations together we get following equation:

p(2,1) =
B(2,2)*(1/6)^2*(5/6)^0 * B(1,0)*(1/6)^0*(5/6)^1 [1]
+ B(2,2)*(1/6)^2*(5/6)^0 * B(1,1)*(1/6)^1*(5/6)^0 * p(2,1) [2]
+ B(2,1)*(1/6)^1*(5/6)^1 * B(1,0)*(1/6)^0*(5/6)^1 [3]
+ B(2,1)*(1/6)^1*(5/6)^1 * B(1,1)*(1/6)^1*(5/6)^0 * p(1,1) [4]
+ B(2,0)*(1/6)^0*(5/6)^2 * B(1,0)*(1/6)^0*(5/6)^1 * R(2,1) [5]

If we simplify all those terms ( biggrin.gif ) for x=2, y=1 we get:

p(2,1) = (1/6)^3 * ( 5 + p(2,1) + 50 + 10*p(1,1) + 5^3*R(2,1))

Now its time to give a formula for R(2,1). If you write down all combinations possible form (1,1,1) to (5,5,5) and look if one of the first to numbers is equal or higher then the last you get the possibility R(2,1).

If you check the old thread, you see, that we already had a solution to calculate how often 1,2,3,.. is the highest number in such a tuple.

k^n-(k-1)^n gives the number of tuples with the maximum number "k" when you roll "n" dice. I.e. if you roll two dice and want to know how many tuples have a maximum number of 2 you get: (1,2); (2,1) and (2,2). 2^2-1^2=3

So we can calculate R(2,1):

In 1^2-0^2=1 cases "1" is the maximum for A, with p=1/5 A wins ( if B has a 1 too).
In 2^2-1^2=3 cases "2" is the maximum for A, with p=2/5 A wins (if B has a 1 or 2).
...
In 5^2-4^2=9 cases "5" is the maximum for A, with p=5/5 A wins (because B can not have a 6).

So R(2,1)= 1/25*1/5 + 3/25*2/5 + 5/25*3/5 + 7/25*4/5 + 9/25*5/5
R(2,1) = (1/5)^3 * (1+6+15+28+45)= (1/5)^3*95

For our case we get:

p(2,1) = (1/6)^3 * (5 + p(2,1) + 50 + 10*p(1,1) + 95)

Substituting p(1,1)=4/7 and solving for p(2,1) we get:

p(2,1) = 1/(6^3-1) * (150+10*4/7) = 218/301 = 0.72425

I will post the general recursive formula to calculate all those possibilities later....
Gorath
Here is my recursive formula to calculate the propability that you beat with your x d6s an opponent with y d6s at an open test...

CODE
p(x,y)= (\sum i=1..x) (\sum j=0..y) B(x,i) * (1/6)^i * (5/6)^(x-i) * B(y,j) * (1/6)^j * (5/6)^(y-j) * p(i,j) (\sum) (\sum) + (1/6)^(x+y)*R(x,y)


with

CODE
R(x,y) := (\sum k=1..5)(\sum n=1..k) (k^x-(k-1)^x) * (n^y-(n-1)^y) (\sum)(\sum)


For this recursive formula you must define:
CODE
p(1,1)=4/7 and p(x,0)=1 and p(0,y)=0.




Now you could calculate all p(x,y). I want to simplify this formula and solve this for p(x,y) so you don't need to solve a equation for p(x,y) in each recursive step. But i will post this next morning...

PS:I hope you see that p(x,y) gives more informations as the expected values E(x), because for x=2 and y=1 you would say E(2)=5.8, E(1)=4.2 so i will allways win (that is not true...). The information p(2,1)=0.7 gives you the information that you will succed in 70%.
gknoy
Wow smile.gif Very nice.

Would anyone else like to implement this (or input it into some Handy Math Calculation Tool (Mathmatica? Matlab?)), or shall I whip up some perl? smile.gif (which, of no one posts numbers, I might. Next week. smile.gif)

One favor, though -- when choosing variables and putting them in monospaced font, Please don't use a lower cased L -- l and 1 look a lot alike. Same for O and 0 ... just as using s and 5 and S is problematic when doing it by hand, a lot of the time. I had a professor that liked to use s, it was bloody annoying. wink.gif

Gorath
When i get some time, i will implify the formula and post some propabilities.Perhaps you could verify p(1,1) and p(2,1) by brute force, so we know the formula is right?

I change the index small "L" in the last sum to n...
gknoy
wow, cool =)

although, in this case, it might be easier to calculate it than to verify by brute force -- simply because the testing seems like it will take a bit of code to do. wink.gif
Gorath
Okay, here it is:

CODE
p(x,y) = 1/(6^(x+y)-1) * (\sum i=1..x-1) (\sum j=0..y-1) B(x,i) * (1/6)^i * (5/6)^(x-i) * B(y,j) * (1/6)^j * (5/6)^(y-j) * p(i,j) (\sum) (\sum) + R(x,y)


and you can simplify R(x,y) even more:

CODE
R(x,y) := (\sum k=1..5)  (k^x-(k-1)^x) * k^y(\sum)


Calculating by hand read.gif i found the following values:

p(1,1) = 4/7 = 0.5714
p(2,1) = 218/301 = 0.7243
p(1,2) = 120/301 = 0.3987
p(2,2) = 6350/11137 = 0.5702

Perhaps someone can check this by doing some runs... proof.gif

We must calculate all p(x,y) because p(x,y) does not equal 1-p(y,x), because "tie goes to attacker".

If my computer works again, i will install Mathematica again and perhaps i can give more results.
phelious fogg
I just wanted to say, I HATE STATISTICS. That said I feel better. Maybe Ill give some time to think of a good combinatorics proof for this over the weekend. Gah, why cant you people ask a math question on Graph Theory or something.. sheesh..

Gorath
I hate statistics, combinatory too. But someone has to do the dirty job rotfl.gif

phelious fogg as you are good in math i would appreciate if you could check my given formulas.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Dumpshock Forums © 2001-2012