PDA

View Full Version : DM Help Dice pool probability



EccentricCircle
2017-05-25, 11:17 AM
As many of you will be aware, various systems use some variation on the "dice pool" mechanic, where you roll a number of dice determined by the stats of your character. The result is *usually* determined by the number of "successes"; how many of the results exceed a target threshold.

I've been trying to figure out how to calculate the probability of certain results, but it turns out that my probability skill is a bit rusty, so hopefully some of the you have more experience working this sort of stuff out.

So first, the bit I *think* I can do:

To work out the chances of a dice within the pool equaling or exceeding a target:

p = (1 - (((t-1)/d) ^n)) x 100

Where:
p = probability expressed as a percentage.
t = target number
d = size of dice (e.g. d6, d10, d20 etc.)
n = number of dice in the pool

So we are essentially working out the probability that you don't beat t and subtracting that from one and multiplying it by 100 to get a percentage.

To get this probability we divide the number one lower than the DC by the number of possibilities on the dice, and multiply it by itself a number of times equal to the number of dice in the pool.

However most dice pool systems need you to get multiples, rather than just one number that beats the DC. For example you might need to get three numbers above seven on a d10, or two above sixteen on a d20.

So how can I expand this equation to work out the probability of getting x number of successes in a given dice pool? (assuming I've got the initial calculation correct that is...).

Red Bear
2017-05-25, 01:22 PM
the probability of getting 3 numbers above 7 (so 8,9 or 10) when throwing 3 d10s is 3/10 x 3/10 x 3/10 = 27/1000 = 2.7%

the probability of getting 2 numbers above 16 (so 17,18,19 or 20) when throwing 2 d20s is 4/20 x 4/20 = 16/400 = 4%

Khedrac
2017-05-25, 03:10 PM
This is one of those "what's the probability of not getting it?" problems.

Take getting 3 or more 7+s on 5 D10:
The way to fail is to get no more than 2
Which means 2 dice are irrelevant = 1 * 1
and the other 3 must be 6 or lower = 6/10 * 6/10 * 6/10
Result - change to 3 7+s is 1-(6^3 10^3) = 1 - (6/10)^3

So in general
D = number of sides on dice
T = target number
Q = quantity of rolls needed over target
P = size of pool

Probability = 1 - ((T-1)/D)^(P+1-Q)
I think.

Edit - seems I did get this wrong, see below for a better answer.

Akodo Makama
2017-05-25, 06:15 PM
For complicated data sets:

Step 1: anydice.com
Step 2:
output [highest 1 of 1d6]
output [highest 1 of 2d6]
output [highest 1 of 3d6]
output [highest 1 of 4d6]
output [highest 1 of 5d6] Calculate, and set data to 'at least'.

erikun
2017-05-25, 06:22 PM
http://anydice.com/ might be helpful for you.

As for dice pools, there is generally a somewhat simple rule of thumb you can use. In general, it is the number of successful faces divided by the number of total faces to determine the chances of success on a single die. For above a 7 on a d10, that's three faces (8, 9, 0) on a ten-sided die, so it is 3/10 or 30% chance of success. (World of Darkness uses an exploding 0, which averages a single die out to 33.3333...% or 1/3 chance.) From there, just multiply the number of dice to determine, on average, how many dice will be needed to succeed. For the 8+ on d10 example, you need around 3 dice to average one success, 6 dice for two successes, and so on.

No, this won't tell you the full probability curve of any particular dice roll, but it will give you a general idea and avoid requiring you to plot probability curves for every possible dice pool result.

As for your other example, if you need to get above 16 on a d20, it would be four faces (17, 18, 19, 20) out of twenty, 4/20, 1/5, or 20% chance for a success on a single die. You'd want an average of five d20 for a good chance of a single success, or ten d20 for a good chance at two successes.

Coventry
2017-05-25, 10:24 PM
This is one of those "what's the probability of not getting it?" problems.

Take getting 3 or more 7+s on 5 D10:
The way to fail is to get no more than 2
Which means 2 dice are irrelevant = 1 * 1
and the other 3 must be 6 or lower = 6/10 * 6/10 * 6/10
Result - change to 3 7+s is 1-(6^3 10^3) = 1 - (6/10)^3

So in general
D = number of sides on dice
T = target number
Q = quantity of rolls needed over target
P = size of pool

Probability = 1 - ((T-1)/D)^(P+1-Q)

I think.

That system does not give you the desired results.

The simplest case is "two coin flips are both heads", which happens 1 time in four random tosses. (tt, th, ht, HH)

Plug the values (D=2, T=2, Q=2, P=2) into your formula, and you get:
1 - ((2-1)/2^(2+1-2) = 1 - (1/2^1) = 1/2.

meschlum
2017-05-26, 12:39 AM
Indeed, you're missing on the combinations in your analysis, as well as suffering from unclear notation.

To go to the original example:

With 5 dice, aiming for three or more successes, there are three cases:

5 successes - probability 0.4^5
4 successes and 1 failure - probability 0.4^4 * 0.6, but there are 5 (5 / 1) combinations (which die is the failure?), so it's 5 * 0.4^4 * 0.6
3 successes and 2 failures - probability 0.4^3 * 0.6^2, but with 10 combinations (5 * 4 / (1 * 2)), so it's 10 * 0.4^3 * 0.6^2

Which gives you 0.4^3 * (0.4^2 + 5 * 0.4 * 0.6 + 10 * 0.6^2), or 0.4^3 * (0.16 + 1.2 + 3.6), so 0.064 * 4.96, which is 0.31744, so 31.744%.


What you were computing only gives you the probability of one or more successes (0.6^5 is the probability of 0 successes, so 1 - 0.6^5 is the probability of anything else, i.e. one or more).

The general form gives you the probability of getting exactly T successes, and then you can compute the sum associated to any set of target successes you want. It's:

S^T * (1 - S)^(P - T) * C(T, P)

Where S is the probability of success, P is the size of your dice pool (must be greater than or equal to T or course), and C is the combinatorial function: C(x,y) is the number of combinations you can have of x dice in a pool of y. It's equal to y! / (x! * (y - x)!), so for instance 2 combinations among 6 dice gives (6 * 5 * 4 * 3 * 2 * 1) / ((1 * 2) * (1 * 2 * 3 * 4)), so 15 (6 * 5 / (1 * 2)).


If you don't need an exact value, anydice will work.

Khedrac
2017-05-26, 03:15 AM
Nice example of my formula going wrong


the actual formula

Thank-you folks for pointing out my error and providing the correct equations.

I find it interesting how many people don't seem to understand how dice pools with success levels work (judging by most of the other responses).

Knaight
2017-05-26, 03:30 AM
If we ignore complications, dice pools are generally binomial distributions (https://en.wikipedia.org/wiki/Binomial_distribution).
You'll notice from the link that there are three variables - n, k, and p. These are the number of trials, number of successes, and probability of one success, respectively. Of these n and k transfer directly, but p needs to be calculated. Using your variables from earlier, you have:

p = (1-((t-1)/d))

Then just use the formulas from the linked page. Some of them use a bit obscure notation, so if you see this:
(a)
(b)

where the parentheses on the two columns are merged together* know that the formula represented is (a!/(b!*(a-b)!)).

A more detailed explanation that's a bit less technical than the wikipedia page is here (http://stattrek.com/probability-distributions/binomial.aspx). nCr is an alternate way of denoting the formula one line up.

*I have no idea how to actually type that on the forum.

Slipperychicken
2017-05-26, 07:16 AM
I strongly recommend using a spreadsheet, your favorite programming language, or another type of calculator so you can just plug in numbers and get an answer without extra time or work.

For shadowrun I made a handful of functions in R, and they've served me well for years.



I find it interesting how many people don't seem to understand how dice pools with success levels work (judging by most of the other responses).

It is fairly common for roleplayers, even ones who are otherwise pretty smart, to assume that they understand dice-related statistics and math far better than they actually do. Maybe it's because we keep throwing around keywords like "stats" or "optimization" that make people feel like they're good at it. It should suffice to say there are good reasons why casinos and other gambling establishments are so profitable.

EccentricCircle
2017-05-26, 07:47 AM
Many thanks for everyone who has replied. This is all making more sense than it was yesterday!

I've put the general formula provided by Meschlum (and vouched for by Khedrac) into a spreadsheet and calculated probabilities for a range of DCs and pool sizes. I've tested this using the binomial calculator on the site Knaight linked to. So I'm pretty happy that the numbers I am getting make sense. However they are not quite giving me the information I'm after.

The next question then is:

How do I allow for more successes than the requisite number?

For example at present the results show very low probabilities of getting 2 successes for a ten dice pool, because of course it is far more likely that you will get more than two successes.

Comparing the results with the numbers I calculated for one success shows a lot of similarity in low dice pools and high target numbers, but massive divergence for low numbers and high dice pools.

Apologies if this is dealt with in the wikipedia page linked by Knaight, I'm finding that very hard to get my head around.

Cluedrew
2017-05-26, 08:44 AM
If we ignore complications, dice pools are generally binomial distributions (https://en.wikipedia.org/wiki/Binomial_distribution).That's the one. Actually ignoring complications, I do believe a dice pool is exactly a binomial distribution. Or a binomial distribution describes the chance of each possible score. To get the pass rate you have to add up the chance of getting each score that allows you to pass. As far as I know, there is no way to simplify that part, but I am in a bit of a rush and have not checked that, anyone know if there is?

EccentricCircle
2017-05-26, 02:11 PM
OK, so let me see if I understand this. If I calculate the probability of getting 2 successes, 3 successes and so on up to the number of dice in the pool and sum those probabilities will it tell me the probability of getting at least 2 successes in a given pool?

Slipperychicken
2017-05-26, 02:53 PM
OK, so let me see if I understand this. If I calculate the probability of getting 2 successes, 3 successes and so on up to the number of dice in the pool and sum those probabilities will it tell me the probability of getting at least 2 successes in a given pool?

You could also sum up the probabilities of 1 and 0 success, then subtract that number from 1. That's a little less computationally expensive (i.e. time-consuming) if you're doing it by hand.

If you're just getting a computer to do it, then it's really not that big a deal either way. The important thing in that case is to write something that's easy for you to understand and maintain.

EccentricCircle
2017-05-26, 03:42 PM
Cheers, I reckon I'll use a computer, doing computations quickly is what they are for after all!

Knaight
2017-05-26, 11:08 PM
How do I allow for more successes than the requisite number?

For example at present the results show very low probabilities of getting 2 successes for a ten dice pool, because of course it is far more likely that you will get more than two successes.
Brute force it - you'll calculate the 2 success case, 3 success case, 4 success case, ... 10 success case and sum them together. Doing this by hand is miserable, doing this in a spreadsheet tedious, doing this in a modern programming language that wasn't deliberately designed to be difficult is a couple of simple for loops. Also R is free and the pbinom (http://www.r-tutor.com/elementary-statistics/probability-distributions/binomial-distribution) function in basically this. It's the probability of getting that many results or less instead of that many or more, so you just use 1 - pbinom(k-1), where k is the minimum number of successes needed.

I personally dislike R as a language, but that's at least partially because MATLAB can do everything R can do and I know MATLAB a lot better than R. It is relatively easy to learn, and for statistics and probability it probably is the single best language, even if there's some weird structural stuff to it.


Apologies if this is dealt with in the wikipedia page linked by Knaight, I'm finding that very hard to get my head around.
Wikipedia is generally a pretty bad source to try and learn math from (and I say this as someone who's had to do it before), but it basically says to do the same thing - it's the CDF formula. Said formula is even less readable without knowing some esoteric notation than the rest of that page, which is a large part of the reason I linked my other, less complete but vastly more accessible source.

EccentricCircle
2017-05-27, 03:23 AM
Thanks. I've used R for a few things before so might give that a try (I'm a scientist, but don't have a background in either stats or programming, so it comes up from time to time for stuff I can't do using Geographic Information Systems.)

That said, I reckon that actually I'm halfway to doing it in a spreadsheet with all the stuff I worked out yesterday while trying to figure this out, so might be able to rearrange that data to add it all up for me.

The second page you linked to was much easier to read, and gave me a lot of confidence that I was understanding what was being explained here. I'll have to bookmark that site for future reference.

Thanks to everyone for all the help.

Knaight
2017-05-27, 04:30 AM
MATLAB and Octave also have a binomial CDF function (binocdf in both), if that language is more to your taste. I even have some Octave code lying around from when I was messing around with reverse dice pool math (the dice are the difficulty and your skill is static, so the math works out about the same:

clc
clear
%Reverse Dicepool Success Calculator
Diffmax = 11; %Number of dice difficulty.
Diemax = 5; %Maximum skill
Snumber = 4 % "Successes", here failures are this or lower on a die.
Diesize = 6 % Number of sides on the die.
Diff = linspace(1,Diffmax,Diffmax);
Skill = linspace(0,Diemax,Diemax+1);
for i = 1:length(Diff)
for j = 1:length(Skill)
P(i,j)=binocdf(Skill(j),Diff(i),(Diesize+1-Snumber)/Diesize);
end
end
disp(P)

Diffmax, Diemax, Snumber, and Diesize are the variables you care about. Diffmax is the maximum number of dice in use, Diemax is the maximum difficulty in a conventional dice pool system, Snumber and Diesize are exactly what they say they are.

It's not very polished code, because it was never intended for more than personal use, and I'm honestly surprised I bothered with even the comments I did. Still, Octave is free, so download it and give this a whirl if you want. It generates a matrix that shows the probabilities of rolling [column] or fewer failures on [row] dice, which is a really weird format for a conventional dice pool that makes more sense for the actual original purpose of the code.

bulbaquil
2017-05-27, 09:30 AM
Also, as a helpful tip:

If for some reason you're looking for the probability of getting EXACTLY N successes, what you want to do is find the probability of getting AT LEAST N successes (much easier to calculate, and usually more relevant), minus the probability of getting at least N+1 successes.

EccentricCircle
2017-05-28, 04:40 AM
After a bit of messing around in Excel last night i've successfully implemented it. It took a bit of fiddling to get everything to sum the correct numbers automatically, but was doable, so not too laborious. The numbers i've got out look to make sense and back up what i've observed when playing and running dice pool games so that's good.
Many thanks to everyone who has contributed to this thread. All the help has been greatly appreciated.

Knaight
2017-05-28, 04:55 AM
Also, as a helpful tip:

If for some reason you're looking for the probability of getting EXACTLY N successes, what you want to do is find the probability of getting AT LEAST N successes (much easier to calculate, and usually more relevant), minus the probability of getting at least N+1 successes.

With binomial probabilities this is exactly backwards - exactly N successes is really easy to calculate (nCr*pkqn-k) using k and n for the nCr value, itself a simple formula.

Lvl 2 Expert
2017-05-30, 04:20 AM
OK, so let me see if I understand this. If I calculate the probability of getting 2 successes, 3 successes and so on up to the number of dice in the pool and sum those probabilities will it tell me the probability of getting at least 2 successes in a given pool?

Yes, exactly.

Let's say you want at least 2 successes in a pool of 4d6 and a succes is a 5.

Your total chance breaks down as
Chance of any single result where you have exactly successes:
2/6*2/6*4/6*4/6
times the amount of individual ways to roll that succes:
4*3/2
Plus the chance of any single result where you have 3 successes:
2/6*2/6*2/6*4/6
times the amount of those:
4 (or 4*3*2/3*2, which is 4)
plus the chance of a result where you have 4 successes:
2/6*2/6*2/6*2/6
times the amount of those:
1
Which in total comes down to:
64/1296*6+32/1296*4+16/1296*1=(384+128+16)/1296=528/1296=88/216=11/27~0.41

For at least 1 succes, you add the chance of rolling 1 succes:
2/6*4/6*4/6*4/6*4=512/1296
This makes the total 1040/1296, or 65/81~0.80

I'm sure there's a more elegant way to do it, but that would be my approach.

EDIT: O wait, too late...

EccentricCircle
2017-05-30, 07:16 AM
EDIT: O wait, too late...

Thanks anyway, but yes, I now have some lovely plots of probability curves which will serve me well in designing dice pool games!

JeenLeen
2017-05-30, 11:07 AM
For shadowrun I made a handful of functions in R, and they've served me well for years.


Would you be willing to post, or PM me, these functions?

Slipperychicken
2017-05-31, 11:06 AM
Would you be willing to post, or PM me, these functions?

Sure thing



#Chance for attacker diepool [atk] to get at least 1 net hit over defender diepool [def]
#Limits [lim] have been implemented for attacker diepool, but not defender diepool
#If no defense entered, assumes no defense (i.e. threshold 1 test)
hitprob<-function(atk,def=0,lim=Inf){
DP1= atk

#possible attack results
atk_result_vector<-c(0:DP1)

#Probabilities of each attack result
atk_prob_vector<- dbinom(atk_result_vector,size=DP1,prob=1/3)

if(lim<( (length(atk_result_vector)-1) )){
atk_prob_vector[lim+1]=sum(atk_prob_vector[(lim+1):(length(atk_result_vector))])
#remove all above limit
atk_prob_vector<-atk_prob_vector[0:lim+1]
atk_result_vector<-atk_result_vector[0:lim+1]
}

DP2= def
#Probability of defense pool equalling or exceeding each attack result
def_prob_vector<-mapply(testprob,thresh=atk_result_vector,diepool=D P2)

#sumproduct of attack probabilities and defense probabilities
hitchance=sum(atk_prob_vector*(1-def_prob_vector))
print(hitchance)
}



#Chance for simple test to beat a threshold
#Assumes the relevant limit is equal to or greater than threshold (otherwise prob is 0)
testprob<-function(diepool,thresh=1){
1-pbinom(thresh-1,size=diepool,prob=1/3)
}

]

#Total Number of Dice rolled in an extended test with diepool [num]
#Used in extprob
tri<-function(num){
num+ (num*(num-1))/2
}


This next one invokes both "tri" and "testprob". It's really just running "testprob" with the number of dice determined by "tri".

#Chance that extended test will eventually succeed
#Uses tri() and testprob()
#Intervals is a maximum number of intervals allowed for the test, as opposed to running out all dice
#If the threshold is not met or exceeded once [intervals] rolls elapse, the test is considered failed
extprob<-function(diepool,thresh=1,intervals=Inf){

if(intervals>=diepool){
testprob(tri(diepool), thresh)
}
else{
testprob( tri(diepool)-tri(diepool-intervals), thresh)
}

}