PDA

View Full Version : Dice probability help (expected successes in a rerollable dice pool)



Zaq
2016-03-09, 02:51 PM
Hey everyone, would any of you be so kind as to help me figure out how to calculate something? I'm trying to figure out what the expected number of successes would be from a batch of dice that you can reroll once. (I'm playing around with AnyDice (http://anydice.com/program/4a06), but I'm not much of a programmer—I haven't done anything involving programming since I took computer science back in high school, which was about 12 or 13 years ago, so I'm really struggling to do anything beyond a single command.)

Basically, say you've got 6d6, and a success is a 6. Anything that isn't a 6 is a non-success and can be treated as identical. If you just roll that pile of dice once and count how many successes you've got, that's simple enough to make AnyDice do: http://anydice.com/program/4a06

But let's say that you've got 6d6 and you're looking for sixes. You can roll that 6d6, and then you can set aside any sixes you rolled and reroll everything that wasn't a success. How do I get AnyDice (or any other dice calculator) to tell me how many successes I can expect in a situation like that? (For the specific situation I'm looking at, it's most important for me to know how that would play out if I reroll once, but it also wouldn't hurt to know what would happen if I rerolled twice.)

Second question: say you've got the same situations, but now we care about 2 faces of the dice. If you roll a 6, that's a success. If you roll a 2, 3, 4, or 5, that's not a success, but it can be rerolled. But, if you roll a 1, that's a failure, and it cannot be rerolled. (It doesn't cancel out a success—it just gives you fewer dice to try to get successes with when you do reroll.) Can someone help me figure out how to make AnyDice (or, again, any other dice calculator) tell me how many successes to expect in a situation like that?

Ideally, I'd like to figure out how to set up a general case for this sort of thing (so that I can make AnyDice calculate different versions of a similar scenario, like how to make it work on 8d6 instead of 6d6, or how to make it work if you can reroll twice but keep the same rules for keeping ones and/or sixes). If you don't want to use AnyDice, I'm open to using any free dice calculator, and if you'd prefer to not use a calculator, I'll do my best to follow your explanation on how to do it by hand (I've never been math-phobic, but it's been a long time since I've needed to use anything other than everyday arithmetic or simple probability calculations like the expected value on a single batch of dice with no rerolls).

Part of what's making this hard is that I'm looking for successes rather than for numbers. I know how to calculate the expected value on 6d6, but I don't really know how to figure out what my odds are of having a given number of successes come up. (Which is one reason I want a dice calculator to do that for me, if possible.) Anyway, any help would be appreciated. Thanks!

Lvl 2 Expert
2016-03-09, 03:12 PM
Basically, say you've got 6d6, and a success is a 6. Anything that isn't a 6 is a non-success and can be treated as identical. You can roll that 6d6, and then you can set aside any sixes you rolled and reroll everything that wasn't a success.
The chance a single die rolls 6 in 2 tries is 1/6+5/6*1/6, or the odds of rolling 6 plus the odds of not rolling six and then rolling six on the next try, =1/6+5/36=11/36 The expected number is the number of dice times those odds is 6*11/36=66/36, or 1 and 5/6th (so close to 2).


now we care about 2 faces of the dice. If you roll a 6, that's a success. If you roll a 1, that's a failure, and it cannot be rerolled. (It doesn't cancel out a success—it just gives you fewer dice to try to get successes with when you do reroll.)
Now a single die gets the odds of 1/6+4/6*1/6=9/36=1/4. Because the odds to not roll six but still get another roll is 4/6. For six dice that's 6/4 or 1 and 1/2. EDIT: I added things up wrong here. For one die it'ss 10/36, so for six dice that's 60/36 = 1 and 24/36 is 1 and 2/3. Not 1 1/2. Thanks Meshlum!

I have no idea how to do it with anydice, but those are the numbers. The calculation is actually pretty similar your own explanation. :smallsmile:

(This gets harder if you want to know say the odds of rolling more then 3 sixes, but the average is surprisingly simple to find.)

Zaq
2016-03-09, 03:43 PM
The chance a single die rolls 6 in 2 tries is 1/6+5/6*1/6, or the odds of rolling 6 plus the odds of not rolling six and then rolling six on the next try, =1/6+5/36=11/36 The expected number is the number of dice times those odds is 6*11/36=66/36, or 1 and 5/6th (so close to 2).


Now a single die gets the odds of 1/6+4/6*1/6=9/36=1/4. Because the odds to not roll six but still get another roll is 4/6. For six dice that's 6/4 or 1 and 1/2.

I have no idea how to do it with anydice, but those are the numbers. The calculation is actually pretty similar your own explanation. :smallsmile:

(This gets harder if you want to know say the odds of rolling more then 3 sixes, but the average is surprisingly simple to find.)

Hmm. That makes sense. I hadn't thought to phrase it in terms of "each die rolling a six within X tries," but when you put it that way, I think I understand how it fits together. So the result you get is the expected number of successes per batch of rolls, right? (With the numbers you calculated in the first paragraph, it would then be accurate to say that if you roll 6d6 looking for sixes and can reroll once, you expect to get 1 and 5/6 successes?)

That definitely helps a lot, so thanks for that. If anyone can figure out how to shove that into AnyDice or into another calculator that will give me a nice breakdown of my chances of getting 0 successes vs. 1 success vs. 2 successes (etc.) without having to calculate them all by hand, I'd be most appreciative, but it's still very helpful to just know the expected number of successes.

Eloel
2016-03-09, 03:47 PM
But let's say that you've got 6d6 and you're looking for sixes. You can roll that 6d6, and then you can set aside any sixes you rolled and reroll everything that wasn't a success. How do I get AnyDice (or any other dice calculator) to tell me how many successes I can expect in a situation like that? (For the specific situation I'm looking at, it's most important for me to know how that would play out if I reroll once, but it also wouldn't hurt to know what would happen if I rerolled twice.)

output [count {6} in [count {1,2,3,4,5} in 6d6]d6] + [count {6} in 6d6]


Second question: say you've got the same situations, but now we care about 2 faces of the dice. If you roll a 6, that's a success. If you roll a 2, 3, 4, or 5, that's not a success, but it can be rerolled. But, if you roll a 1, that's a failure, and it cannot be rerolled. (It doesn't cancel out a success—it just gives you fewer dice to try to get successes with when you do reroll.) Can someone help me figure out how to make AnyDice (or, again, any other dice calculator) tell me how many successes to expect in a situation like that?

output [count {6} in [count {2,3,4,5} in 6d6]d6] + [count {6} in 6d6]



Ideally, I'd like to figure out how to set up a general case for this sort of thing (so that I can make AnyDice calculate different versions of a similar scenario, like how to make it work on 8d6 instead of 6d6, or how to make it work if you can reroll twice but keep the same rules for keeping ones and/or sixes). If you don't want to use AnyDice, I'm open to using any free dice calculator, and if you'd prefer to not use a calculator, I'll do my best to follow your explanation on how to do it by hand (I've never been math-phobic, but it's been a long time since I've needed to use anything other than everyday arithmetic or simple probability calculations like the expected value on a single batch of dice with no rerolls).


N: 6
output [count {6} in [count {2,3,4,5} in Nd6]d6] + [count {6} in Nd6]



I hope that works for you :)

Lvl 2 Expert
2016-03-09, 04:28 PM
Awesome, I'm going to use those functions sometime.

There is a detail going wrong somewhere though, the means I get from those functions are 1.01 and 1.03, or .01 and .03 higher than the mean for just rolling 1d6. And the higher mean comes from the scenario where you can't reroll one's. And the maximum number of successes on both cases is 7.


So the result you get is the expected number of successes per batch of rolls, right? (With the numbers you calculated in the first paragraph, it would then be accurate to say that if you roll 6d6 looking for sixes and can reroll once, you expect to get 1 and 5/6 successes?)

Exactly.

Eloel
2016-03-09, 05:25 PM
Awesome, I'm going to use those functions sometime.

There is a detail going wrong somewhere though, the means I get from those functions are 1.01 and 1.03, or .01 and .03 higher than the mean for just rolling 1d6. And the higher mean comes from the scenario where you can't reroll one's. And the maximum number of successes on both cases is 7.


...

I made an error. I'll work on it.

Eloel
2016-03-09, 06:30 PM
http://anydice.com/program/7dcb

I managed to finally get it to work. The stupid thing about AnyDice is sending a dice into a function "fixes" it for calculation purposes (whereafter you can use it multiple times without issues), while simply using a variable it "rerolls" for every usage of the variable. So,



function: onesixcounter X:s{
result: [count 1 in X] + [count 6 in X]
}
output [onesixcounter 1d6]

X: 1d6
output [count 1 in X] + [count 6 in X]

give different results

meschlum
2016-03-10, 12:08 AM
Easy!

If you get one reroll on 1-5, then your probability of getting one success on 1d6 is 11/36, as shown above.
If you get one reroll on 2-5, then your probability of getting one success on 1d6 is 10/36, again as above.

In both cases, you can't get more than one success, and you're not getting any 'negative' successes, so what you have is N 'dice' which give a success with probability 11/36 or 10/36, instead of the more traditional 1/6 (6/36) you get using an ordinary die.

That means we're just using a standard binomial distribution, which means the odds of getting k successes with N dice are easy to compute.

Let p be the probability of getting a success on one die (11/36 or 10/36 in this case).

0 successes: (1 - p)^N
1 success: p * (1 - p)^(N - 1) * N
2 successes: p^2 * (1 - p)^(N - 2) * N * (N - 1) / 2
...
k successes: p^k * (1 - p)^(N - k) * N! / (k! * (N - k)!)
...
N - 1 successes: p^(N - 1) * (1 - p) * N
N successes: p^N

Things only get notably annoying to work out if one die can give more than two outcomes.


Edit: I'm not familiar with anydice, but you can get exactly what you're after by just using a d36 - count 1 to 11 on a d36 (or 1 to 10 if you don't reroll ones) and you get the exact statistics you're after in the format you want. No need to use complicated formulas.

If you have two rerolls, it's a d216, but the principle is the same. (91 / 216 with 1-5, and 76 / 216 with 2-5 and no rerolls on 1)