# Thread: [Math] Calculating Dice for Success Tests

1. ## [Math] Calculating Dice for Success Tests

Assuming the following

S = total number of successes needed
d = total number of dice rolled

P(success on a die roll) = 0.33

How would you calculate the number of dice you need to roll to roll S successes with probabilistic certainty (e.g. P(S)=1)?

Or what is a good rule of thumb? Though I would like the general answer as well, if possible

2. ## Re: [Math] Calculating Dice for Success Tests

The following assumes you are performing d binary simulations with probabilities P(True)=1/3 and P(False)=2/3 and attempting to calculate the probability of generating s "True" outcomes.
e.g.: You have some 3-sided dice. You roll d of these dice. You will calculate the probability of s 3s being rolled.

P(s | d)* = (1/3)d-s(2/3)sdCs

*read: Probability of s successes given d rolls.

That, however, is not exactly what you seek. To calculate the probability of rolling at least s successes, you need to add the probabilities of rolling any given number of successes equal to or greater than s. You can either add the probability of all these outcomes together, or add all the probabilities of rolling less than s successes together and subtract from 1.

I'm trying to think of how a formula might be generated for this...

[EDIT]: Wait, I don't think this is even close to what you seek. Rereading your post, you want to know how many dice you need roll at P(Success on a single die)=X so that P(Success on at least one die)=1. To find this:

P(Success on at least one die) = 1 - P(Failure on all dice) = 1 - (1-X)d
if P(Success on at least one die) = 1
then P(Failure on all dice) = 0
then 0 = (1-X)d
then Log(1-X)(0) = d

Basic familiarity with logarithms will inform you that no solution for the variable d exists, because logarithms are undefined** when evaluated at numbers less than or equal to 0.

** Specifically, the limit approaches -inf from the right, and IIRC negative arguments produce imaginary outputs.

[EDIT2]: More practically, you could calculate your "break even" point fairly easily. i.e.: P(Success) = .5

if P(Success) = .5
then P(Failure) = .5
then .5 = (1-X)d
then Log(1-X)(.5) = d

Specifically, in the case of X = .33:

d = 1.7095

And thus, you need to roll at least 2 dice to have a 50% or better chance at success.

3. ## Re: [Math] Calculating Dice for Success Tests

Whups, I was looking more for "if I need at least 3 successes, how many dice should I roll?"

4. ## Re: [Math] Calculating Dice for Success Tests

Well, you'll never have P(at least S successes in d rolls) = 1 with a finite value for d and a positive S. What you're describing is essentially a negative binomial random variable, where for some integer k > 1 the result is the number of independent and identical Bernoulli trials (dice rolls, in this case) it takes to get the k'th success.

The probability of it taking y rolls to get k successes, where p is the probability of any given roll being a success is

P(y) = (y-1)!/((k-1)!(k-r)!)*p^k*(1-p)^(y-k)

and the expected result (basically the average number or rolls to get k successes) = k/p

I'm writing this mostly from memory and with only a bit of checking, so since I'm not a statistician I could easily have screwed the above up.

5. ## Re: [Math] Calculating Dice for Success Tests

To get one success you need on average 3 dice. You are much safer with 4 per hit. Shadowrun 4th edition uses a mechanic like that where you have Xd6, and count the number of times you got 5 or 6. It is advised that you can buy successes at a rate of 4 to 1.

Though there have been a couple of times where I threw 12 dice and got only 1 hit so its not a certain thing.

To calculate near certainty use this formula. This is to get one and only one success.

P(1)=1 - (2/3)^n, where n is the number of dice you roll. From there you figure out n, depending on how sure you want to be.

6. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by Oracle_Hunter
Whups, I was looking more for "if I need at least 3 successes, how many dice should I roll?"
I might have missed the point, but isn't this an unanswerable question? The probability of getting at least n successes is never going to be 1 in a WoD style success system.

What you can calculate instead is a threshold; if you know what you would consider to be an acceptably high probability of success (90%, say), then you can calculate how many dice you need to roll to reach that point.

7. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by Oracle_Hunter
Whups, I was looking more for "if I need at least 3 successes, how many dice should I roll?"
That's just "how many dice should I roll before I can expect three successes".

It's a binomial distribution, so your expected number of successes equals (number of dice) x (probability of success). I'm not sure if that's exactly what you want, however.

It's pretty normal to assume something's up if the probability of your result (given that nothing is up) is less than 5%. I don't think there's a quick and easy way to deal with cumulative binomial distributions.

Note that Shadowrun has a 1 in 3 probability of success - in NWoD, you expect 1/3rd of a success per dice rolled, even though the probability is only 30%.

8. ## Re: [Math] Calculating Dice for Success Tests

You're never going to be 100% certain of rolling those three succeses no matter how many dice you roll. You have to specify an acceptable margin of failure.

9. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by RebelRogue
You're never going to be 100% certain of rolling those three succeses no matter how many dice you roll. You have to specify an acceptable margin of failure.
Hmm... well if probabilistic certainty is impossible, then let's go with 95% - that's the usual bar in statistics IIRC.

Oh, curse my weak math-fu

10. ## Re: [Math] Calculating Dice for Success Tests

A good rule of thumb is: If you have a one-in-N chance of success per die rolled, then you should be rolling at least N dice per success required. I'm not sure how accurate this is, I'll leave the exact mathematics to others.

11. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by Oracle_Hunter
Assuming the following

S = total number of successes needed
d = total number of dice rolled

P(success on a die roll) = 0.33

How would you calculate the number of dice you need to roll to roll S successes with probabilistic certainty (e.g. P(S)=1)?

Or what is a good rule of thumb? Though I would like the general answer as well, if possible
I've done quite a bit of math with WoD types.

What you actually have there is an expected value of number of successes per roll (Not the chance of a success on a roll. That is always 0.3 - the explosion isn't counted). In otherwords, you can construct the equation:
E(S/R)=1/3 [Works out exactly]
So if you want 9 Rolls:
E(9S/R) = 9E(S/R) = 9*0.33 = 3
So, if you roll 9 rolls you are Expected to get 3 successes.
From this, you can easily construct the equation: D/3=S or 3S = D.
That is: If you want S successes, you need at least Three times S in dice to regularly achieve it.

Spoiler

Code:
Proof:
E(S/R) = 0*(7/10) + 1 * 2/10 + 1/10*(1+E(S/R))
E(S/R) = 2/10+1/10+1/10 * E(S/R)
9/10 E(S/R) = 3/10
9 E(S/R) = 3
E(S/R) = 3 / 9 = 1/3.

EDIT:
Oops, I think the P = E in this particular case, and I'm wrong. Doesn't matter.

Originally Posted by Oracle_Hunter
Hmm... well if probabilistic certainty is impossible, then let's go with 95% - that's the usual bar in statistics IIRC.

Oh, curse my weak math-fu
What you essentially have is X Trials with Y success and X-Y Failures -> This is a binomial.
So, if you have D dice, and S successes, without accounting for the explosion you have a PDF of the form:
P(S) = D Choose S * (P(S/Roll))^S * (1-P(S/Roll))^(D-S)
P(S) = D!/(S!*(D-S)!) * (P(S/Roll))^S * (1-P(S/Roll))^(D-S)
And you want to solve for D.

The Math for that sucks, so I'll leave it as an exercise for you :P

12. ## Re: [Math] Calculating Dice for Success Tests

OK, well, you need to know how to calculate a binomial coefficient:

(n r)T = n!/(r!(n-r)!)

Then, where S is the actual number of successes rolled, s is the desired number, and d is the number of dice:

P(S=s) = (d s)T(1/3)s(2/3)(d-s)

Unfortunately, I don't think there's a shortcut (if you're not happy just knowing the mean number of successes) to working out when the probability of not getting enough successes is less than five percent.

By the way, the (n r)T means that the 'n' is supposed to be directly above the 'r' but I couldn't quite write it that way.

13. ## Re: [Math] Calculating Dice for Success Tests

Something missing from all of this:
What is your target number? Exalted style (7)? WoD style (variable)? If WoD, what target are you aiming for?

14. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by SweetRein
Something missing from all of this:
What is your target number? Exalted style (7)? WoD style (variable)? If WoD, what target are you aiming for?
From the OP, I assumed that this was for Shadowrun (or possibly some less well-known system).

15. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by Oracle_Hunter
Assuming the following

S = total number of successes needed
d = total number of dice rolled

P(success on a die roll) = 0.33

How would you calculate the number of dice you need to roll to roll S successes with probabilistic certainty (e.g. P(S)=1)?

Or what is a good rule of thumb? Though I would like the general answer as well, if possible
To do it much less mathematically–in Exalted, with target number 7 and 10's counting for two, you will get approximately one success for every two dice you roll, on average. I'm not sure exactly how this ports over into WoD, but I can probably come up with something if you tell me the mechanics.

16. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by lesser_minion
OK, well, you need to know how to calculate a binomial coefficient:

(n r)T = n!/(r!(n-r)!)

Then, where S is the actual number of successes rolled, s is the desired number, and d is the number of dice:

P(S=s) = (d s)T(1/3)s(2/3)(d-s)

Unfortunately, I don't think there's a shortcut. I think you're going to have to tabulate the results and pick out ones you like.

By the way, the (n r)T means that the 'n' is supposed to be directly above the 'r' but I couldn't quite write it that way.
It is true that this will give you the probablility op rolling exactly s successes, but rolling more than that is good too. So you need the cumulative probablity, summing up the probabilities of all those outcomes.

17. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by RebelRogue
It is true that this will give you the probablility op rolling exactly s successes, but rolling more than that is good too. So you need the cumulative probablity, summing up the probabilities of all those outcomes.
I don't think you do need a Cumulative distribution.
CDF is defined as rolling P(x <= X). Reliability is defined as rolling P(x > X). I imagine you don't want to roll LESS successes, so you may actually want the Reliability.

Reliability is 1-CDF.

Edit: Found it
Code:
R(x) = \sum_{floor(x) +1}^n n choose k p^k (1-p)^(n-k)

18. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by RebelRogue
It is true that this will give you the probablility op rolling exactly s successes, but rolling more than that is good too. So you need the cumulative probablity, summing up the probabilities of all those outcomes.
Yes, that's why I wrote P(S=s) as opposed to P(S<=s).

According to Google, you can start using the normal distribution once you have fifteen or more dice, at which point you can start pulling answers from tables.

The number you'll need to look up is usually called z, and given by:

z = (3s - d)/sqrt(2d)

You need P(Z <= z|Z ~ N(0,1)) to be 0.05 or less.

I don't think you do need a Cumulative distribution.
CDF is defined as rolling P(x <= X). Reliability is defined as rolling P(x > X). I imagine you don't want to roll LESS successes, so you may actually want the Reliability.
I read it as wanting a failure to be statistically significant, so you're looking for values of d where P(S <= s) is 0.05 or less.

19. ## Re: [Math] Calculating Dice for Success Tests

- A success is a 5-6 on a d6 (so, 0.33 chance of a success)
- If I could do the math for the probability calculation, I wouldn't have asked

Still, I guess the (intuitive) 3*S calculation must be accurate.

The main reason I'm asking is because, in a game of Bliss Stage, two of my Players (a Chemist and a Programmer) were capable of rolling highly efficiently; they were able to get just enough Successes to pass everything but didn't have so many extra dice around that they took a lot of "damage."

When I asked how the devil they were doing that, they said that you can calculate the number of dice you need in advance. I refuse to believe that they just had an exceptionally strong case of Good Luck, and if there is SCIENCE behind it, I must know!

20. ## Re: [Math] Calculating Dice for Success Tests

I'm actually taking Data Management in High School right now just so I know how to do these types of thing.

Of course, half the class is stuff I already know, so it is really really really boring, but sacrifices must be made.

21. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by Oracle_Hunter
- A success is a 5-6 on a d6 (so, 0.33 chance of a success)
- If I could do the math for the probability calculation, I wouldn't have asked

Still, I guess the (intuitive) 3*S calculation must be accurate.

The main reason I'm asking is because, in a game of Bliss Stage, two of my Players (a Chemist and a Programmer) were capable of rolling highly efficiently; they were able to get just enough Successes to pass everything but didn't have so many extra dice around that they took a lot of "damage."

When I asked how the devil they were doing that, they said that you can calculate the number of dice you need in advance. I refuse to believe that they just had an exceptionally strong case of Good Luck, and if there is SCIENCE behind it, I must know!
I suspect that they were mostly just using expected results - in this case, you should have a better-than-even chance of doing at least as well as expected (I think - I don't really want to work out the proof).

It's the only piece of maths here that can be done in seconds, unless they bring a few databooks to the table.

Originally Posted by Oracle_Hunter
- A success is a 5-6 on a d6 (so, 0.33 chance of a success)
- If I could do the math for the probability calculation, I wouldn't have asked
Well, we explained how to do it. Nobody does all of this by hand any more - it's just stuff that might have to be translated and put onto a spreadsheet.

22. ## Re: [Math] Calculating Dice for Success Tests

I once drew up a table. Technically it was a table to determine the statistical probability of "2-pair" occuring in a hand of cards. It took about an hour and a half of just cranking numbers.
It occurs to me that a similar thing could be done ahead of time. If you knew, in your head, how many dice you would have to roll to achieve a 95% success ratio, you could easily decide to roll that many dice any time a challenge came up, given that you could choose any number of dice to roll.
It just requires a lot of work in advance, and then memorizing a table.

23. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by lesser_minion
Well, we explained how to do it. Nobody does all of this by hand any more - it's just stuff that might have to be translated and put onto a spreadsheet.
Well yeah, but I figured there might be a simplified solution, somewhere.

24. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by Oracle_Hunter
Well yeah, but I figured there might be a simplified solution, somewhere.
There might be tables somewhere on teh interblag, and I'm pretty sure I saw at least one java applet as well.

25. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by Oracle_Hunter
Well yeah, but I figured there might be a simplified solution, somewhere.
So, out of x dice of 6 sides, you want to know how many can be kept in order to make it average - preferring just above - at the target value?
3d6 to 1 will actually provide /just/ under the target. And I would suspect that is what they are using.

4d6 to 1, then +3d6 for each 1 above that per 7 total, resetting, so:

4d6 : 1 Success (4d6)
7d6 : 2 Success (3d6)
10d6 : 3 Success (3d6)
13d6 : 4 Success (3d6)
16d6 : 5 Success (3d6)
19d6 : 6 Success (3d6)
22d6 : 7 Success (3d6)
26d6 : 8 Success (4d6)
29d6 : 9 Success (3d6)
etc.

Should work. It holds til you get upwards of 64 Success. At which point you need to add another (3d6) in there. I don't think you will need much higher than that...
edit: calculated using a gaussian summation formula, taking the average for a targeted "keep" amount of dice, and then summed together to try to target a single "5" (or higher) per, preferring to er on the side of "just over" than "just under"

edit2:
Made a quick script for you to play with:
http://pifro.com/tempmove/targetthis...des=6&Target=5

The Dice is the number of dice you a rolling. Sides is sides of the dice (d6), and target is target number for a success.
It throws 1000 random sequences of dice between 1 and Sides and spits out the average number of success.
Though, this appears to be showing my calculations to be a bit high. Huh.

26. ## Re: [Math] Calculating Dice for Success Tests

The inaccurate (especially at low numbers of rolls, such as in this problem) is to hit it with the central limit theorem.

We have coin with a 1/3 chance of landing on +1, and a 2/3 chance of landing on +0.

Estimate how many coins it takes to have a 97.5% chance of getting a 3 or higher.

E( n C ) = n/3 (exact)
V( n C ) = n V( C ) =~ n 2/9 (central limit theorem, horribly abused)
SD( n C ) = sqrt V( n C ) = ~sqrt(n) sqrt(2)/3
2 SD( n C ) =~ 95% confidence radius. (is really ~1.96, but 2 is easier).
E( n C ) - 2 SD( n C ) =~ n/3 - 2 sqrt(n) sqrt(2)/3 (which is the lower bound of the 95% confidence interval)

Solving for 3:
3 = n/3 - 2 sqrt(n) sqrt(2)/3
9 = n - sqrt(n) sqrt(8)
Let x := sqrt(n)
x^2 - sqrt(8) x - 9 = 0

Candidates for x are [ sqrt(8) +/- sqrt( 8 + 36 ) ] / 2
= sqrt(2) +/-sqrt(11)
negative x is non-physical I suspect
= sqrt(2) + sqrt(11)
x = 4.7308383527284948979166214608804
as x = sqrt(n), n = 22.38

So if you roll 23 dice with a 1/3 chance of success, you'd expect a 97.5% chance to get at least 3 successes.

Hmm I think I made an algebra mistake.

With 2/3 failure chance and 23 dice...

P(0 successes) = (2/3)^23
P(1 success) = 3^-23 * 2^22 * 23
P(2 success) = 3^-23 * 2^21 * 23*22/2
P(0+1+2 success) = 635437056/3^23
So, using exact mathematics, we get a 99.3% chance that 23 dice get at least 3 successes.

I probably missed an order of magnitude somewhere. What if the negative x isn't non-physical? Then we get 4 dice being enough, which doesn't seem reasonable.

Oh well. Anyone care to find my error?

27. ## Re: [Math] Calculating Dice for Success Tests

Well, just looking at the concept of your math - there is the additional issue that "they were able to get just enough Successes to pass everything but didn't have so many extra dice around that they took a lot of "damage.""
Was mentioned. Which I took as meaning that just getting the chance isn't enough. You must get the chance without risking going very far over.

28. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by SweetRein
Well, just looking at the concept of your math - there is the additional issue that "they were able to get just enough Successes to pass everything but didn't have so many extra dice around that they took a lot of "damage.""
Was mentioned. Which I took as meaning that just getting the chance isn't enough. You must get the chance without risking going very far over.
In which case your best bet is the Expected Value, erroring on the side of just a bit over.

29. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by Oracle_Hunter
Hmm... well if probabilistic certainty is impossible, then let's go with 95% - that's the usual bar in statistics IIRC.

Oh, curse my weak math-fu
R is a free statistical computing package that I believe can calculate this for us. I use it sometimes at grad school when the professor prefers it to MATLAB. I'm not super-familiar with it, and I'm a noob with programming anything, so I might screw up, but I think it works out...

> s=3
>
> k <- seq(0, 50, by = 1)
>
> x=qbinom(0.05,k,1/3)
>
> which(x==s)
[1] 18 19 20 21

So according to my shoddy R programming you'd need 18 trials where p(success)=1/3 to have a 95% chance of getting 3 or more successes. Let's sanity check this with s=1000.

> s=1000
>
> k <- seq(0, 5000, by = 1)
>
> x=qbinom(0.05,k,1/3)
>
> which(x==s)
[1] 3130 3131 3132

A little above 3*s seems right as we converge to Central Limit Theorem probability limit, pardon my edit.

Here's s=5 and s=10 for fun:

[1] 26 27 28 29 (so 26 rolls for 5 successes)
[1] 45 46 47 48 (45 rolls for 10 successes)

Hope this helped!

30. ## Re: [Math] Calculating Dice for Success Tests

Originally Posted by SweetRein
Which I took as meaning that just getting the chance isn't enough. You must get the chance without risking going very far over.
Very true!

This is why really accurate measures are so annoying - barring bad luck, there's just not much I (as DM) can do to them. And the story bogs down, because we can't get past a major plot point until someone dies

Yeah, it's a fun game

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•