Counting fails and successes in dice pools in Anydice

I'm trying to figure out probabilities for a d6 dice pool mechanic where [5,6] are successes, and [1.2] are fails causing the player to lose that dice from the pool.

I've been using "output [count {1,2} in Nd6]" to get the probability of either result happening in N sized pool. But these are independent of each other - I want to figure out how many fails would happen during a success?

e.g. Pool 3d6, if there are at least two successes (27%) how many fails would there be? I assume a 33% chance of one fail, as there's only one remaining dice if two are assumed as successes.

I feel like that would generally be true (e.g. 7d6 pool, 3 successes, 'd just look at the probabilities of fails in 4d6). But it would be nice if I could combine them into a procedure in Anydice.

Any suggestions? Or am I way off with my understanding of probabilities?

• Welcome! You can take the tour as an introduction to the site and check the help center for further guidance. Good luck and happy gaming! – Sdjz May 24 at 13:11
• Related, maybe a functional duplicate: How to calculate conditional probabilities in anydice? : essentially, anydice doesn't do conditional probabilities easily, but you can kind of hack it by writing a function which rerolls if the output you got didn't satisfy your sampling criteria *(e.g. didn't get at least 2 successes). – Carcer May 24 at 13:17

For an exact number of assumed successes, your logic is fine, except for what might be just a typo: the dice that are not successful cannot roll a number greater than 4, so they're effectively d4s, not d6s. For example, assuming exactly $$\k\$$ successes (i.e. rolls of 5+) out of $$\n\$$, the distribution of failures is the same as if you rolled $$\(n-k)\$$d4 and counted failures (i.e. rolls of 1 or 2) among those.

Here's an AnyDice script demonstrating this, using the "empty die trick" described in this answer to calculate the conditional probabilities.

For at least $$\k\$$ successes, however, you also need to consider the cases with $$\k+1\$$, $$\k+2\$$, ..., $$\n\$$ successes, and take a weighted average of the failure counts in each case (with the weights given by the probabilities of rolling each possible number of successes).

In particular, the probability of getting exactly one fail, assuming that there are at least two successes, on 3d6 is not 33%; it's actually 3/7. There are two ways to calculate this by hand:

1. The probability of rolling exactly two successes on 3d6 is $$\3×(1/3)^2×(2/3)=2/9\$$, while the probability of rolling three successes is $$\(1/3)^3=1/27\$$. The conditional probabilities of getting one failure in those two cases are, of course, $$\1/2\$$ and $$\0\$$ respectively. Thus, the probability of getting one failure if there are two or three successes is $$\frac{(1/2)×(2/9)+0×(1/27)}{2/9+1/27} = \frac{1/9}{6/27+1/27} = \frac{3/27}{7/27} = 3/7.$$

2. Denoting success with S, failure with F and neither with -, there are seven possible outcomes with two or more successes: SSF, SS-, SFS, S-S, FSS, -SS and SSS. Each of those is equally likely (since each die is equally likely to roll a success, a failure or neither), and out of those, exactly three have one failure.

Of course, we can also modify the AnyDice code above to calculate the number of failures on $$\k\$$ or more successes. The screenshot below shows the output for $$\n=4\$$:

• I think your results demonstrate that the OP's simple logic is not correct, not that it is! (the OP suggests that expected failures in 7d6 assuming 3+ successes might be equal to expected failures in 4d6) – Carcer May 24 at 17:13
• Can you explain a bit about why that logic is wrong? (I do worry its too simple, and that's often misleading in probabilities!). 7d6 has whatever chance of getting 2 fails. But if we posit that 7d6 has been rolled and 3 of them are successes, then those three dice noonfer have any possibility of being fails, so the overall possibility of 2 fails must diminish based on this information. My assumption would be that it would return to whatever possibility 4d6 has, as those four other dice are free to be successes, fails or neither. – Macallan Lehane May 25 at 8:20
• @Carcer: Reading the question more carefully, you do have a point: the OP's logic has some mistakes that I mentally corrected while reading it. I've edited my answer. – Ilmari Karonen May 25 at 13:49
• @MacallanLehane: If you're assuming exactly three successes, then the remaining four dice can only be failures or neither. If you're assuming at least three successes, things get more complicated; see my edit above. – Ilmari Karonen May 25 at 13:52
• @MacallanLehane conditional probability is complicated and rarely aligns with human intuition. If you rolled 7d6 and randomly removed 3 dice from it, the expected successes on the dice that remained would be the distribution for 4d6; but when you selectively remove dice from the pool based on other criteria, the expectation of what's left is affected in a more complex way. – Carcer May 25 at 14:01