cellio: (avatar)
Monica ([personal profile] cellio) wrote2004-11-23 11:53 pm
Entry tags:

D&D and probability

Tonight's D&D game (fun game, but more about that later) involved a big fight (a duel of sorts), which we'd been able to plan for in advance. The result of this has been a lot of email over the last week or so, which has been interesting. And because some of us are geeks, part of that volume of email has been dedicated to a discussion of probability theory.

The opponents had proposed entering the arena with no preparatory spells cast and then rolling dice each round to see when to start the attack. (Until then we'd be able to take defensive measures.) This led to a discussion of how many rounds of prep to expect for any given die-rolling proposal. (That's "expect" as in "expected value", not "expect" as in "really think this will happen every time", of course.)

This is a simple probability problem, if you're up on your probability theory. The three people who explicitly tried to answer the question used three different approaches.

I, being rather distant in time from formal math of any sort, took the intuitive approach: for N equally-probable outcomes, the expected value is N/2. (I'll justify this error in comments if asked. There was actual reasoning behind it, not just a guess.) Ralph wrote a perl script to run simulations, and came up with the same results as Kevin, who applied formal theory. Sure, it's obvious that the answer is log(0.5)/log(1-1/N), right? Um, yeah. Sure. Whatever you say. If he didn't have the perl script backing him up, I'd be more argumentative.

I think this is an illustration of why formal math and I do not get along. I started college life as a math major, but it didn't stick. I'm just fine if I can relate a theory to actual facts I can really observe and understand, but if it's all "sure, whatever you say" to me, then I have trouble conjuring up the correct invocations from memory on demand, and that's what the exams were all about. In a real-world context I do not yet understand why the probability of a 1-in-10 event is 6.6 rather than 5.5. [Edited to add: Sloppy writing -- I meant the expected number of trials before a 1-in-10 event occurs, not the probability.] And if I can't understand it, there's no reasoning involved -- just number-crunching.

This is kind of bizarre when you think about some of the theoretical contexts I'm perfectly comfortable working in. But there you have it: why advanced calculus and everything that followed seemed completely foreign to me.

Oh, as for what actually happened? We wanted to get about 10-11 rounds of prep, so we opted for a match on 2 d20s. The expected value from that would have been 12-13 rounds, which was good enough. It actually went 48. So much for theory. :-)

[identity profile] sui66iy.livejournal.com 2004-11-24 05:24 am (UTC)(link)
I realize you're being informal here, but you're being *so* informal that I can't even tell what you're trying to compute. For instance, the phrase "In a real-world context I do not yet understand why the probability of a 1-in-10 event is 6.6 rather than 5.5" makes no sense. A probability is a real number betwen 0 and 1. It can't be 6.6 or 5.5. Do you mean to ask what the expected value of one roll of a ten-sided die is or something? (The answer to that is 5.5, unless you've got some exotic kind of die I don't know about...) Expected value (for discrete variables) is the sum of each value multiplied by its probability. For a fair die, this is:

0.1(1) + 0.1(2) + 0.1(3) + ... + 0.1(10)

which is 5.5.

[identity profile] ralphmelton.livejournal.com 2004-11-24 05:26 am (UTC)(link)
We've established that for a chance p of ending the cycle on any roll, the expected number of rounds of prep is 1/p, but the median is log(.5) / log(1 - p). I don't know why the median works out that way either.

[identity profile] eub.livejournal.com 2004-11-24 06:29 am (UTC)(link)
took the intuitive approach: for N equally-probable outcomes, the expected value is N/2

Your intuition is giving the (almost) correct answer to a slightly different problem: number of trials to get a specified outcome, for N equally probable outcomes without repetition. If you're drawing from a deck of cards, on what draw will you pull the ace of spades? Expectation is (52+1)/2.

If you're rolling a 52-sided die, though, or putting the drawn card back in the deck each time, you can get the same "wrong" outcome more than once, so it takes longer to get the "right" one -- expectation is N, and it's interesting that this result is simpler-looking than the other, but not directly accessible to any intuition I've got.

E = 1/n + (n-1)/n (1 + E) = 1 + (n-1)/n E
1/n E = 1
E = n

[identity profile] eub.livejournal.com 2004-11-24 07:40 am (UTC)(link)
It actually went 48.

Let's see, theory says 48 or higher will happen... (19/20)^48 = 9% of the time. :)

[identity profile] dragontdc.livejournal.com 2004-11-24 08:08 am (UTC)(link)
This is why the old 1st (and 2nd, I believe) edition DMG had the bell curves graphed in the front of the book for the various dice.

[identity profile] lyev.livejournal.com 2004-11-24 04:18 pm (UTC)(link)
I do not yet understand why the probability of a 1-in-10 event is 6.6 rather than 5.5. [Edited to add: Sloppy writing -- I meant the expected number of trials before a 1-in-10 event occurs, not the probability.] And if I can't understand it, there's no reasoning involved -- just number-crunching.

Actually in each trial the probablility is 1 in 10, but what you're asking for is the number of trials it would take to increase the cumulative chance above 50%

For example, take a d10 v. d10

The chance of a match on trial one is 10% (no surprise!)

The chance of a match *by* trial two is the sum of the chances of a match on trial one and on trial two. Trial one's prob is 10%, as above. So the chance that trial two actually happens is 90%. (we are assuming the dice rolling ends on a match, otherwise your reasoning works!)
So the chance of a match of trial two is the chance of trial two happening (90%) times the chance of a match (always 10%)

This gives 9%. Adding it to the chance of a match on trial one gives 19%. Note that this is < 20% ;-)

The chance of a match happening by trial three or earlier is:
10% + (90%)*(10%) + (81%)*(10%) = 10% + 9% + 8.1% = 27.1%
Note that this is < 30% ;-)

So by five trials, you will have some number <50% Thus you'll need to do more than five trials to get above a 50% chance of a match "on or before the nth trial" Actually, since the question was phrased in terms of time before the match happens, it's more like you're saying that it's better than 50% that a match *won't* happen on or before roll number 5, and thus that you have a better than 50% chance of 5 rolls happening.

Make some sense?

[identity profile] dr-zrfq.livejournal.com 2004-11-24 04:53 pm (UTC)(link)
Oh, as for what actually happened? We wanted to get about 10-11 rounds of prep, so we opted for a match on 2 d20s. The expected value from that would have been 12-13 rounds, which was good enough. It actually went 48. So much for theory.

You forgot to take into account the innate perversity of gaming dice. ;->

[identity profile] ralphmelton.livejournal.com 2004-12-03 03:39 am (UTC)(link)
I still look forward to the 'more about that later'. (Though I have been derelict about posting about it myself.)