Probability

From 2d4chan
Jump to navigation Jump to search

Can you into probability and statistics?

  • No? Start reading.
  • Yes? Start editing. Know your audience, explain things for ordinary people. If I see any greek letters in here I'll bite off your kneecaps.

The Basics

Relevant for: Everything

Notation/How do I write this stuff?

I'm assuming you know that a d4 is a four-sided-die, and 2d4 is two four-sided-dice. If you're confused regarding dice notation, see dice.

In order to preserve the most information when writing anything, it's good practice to write your probabilities as (number of desired events)/(number of total possible events). The probability of rolling a 4, 5 or 6 is written as 3/6.

While 3/6 is numerically equivalent to 1/2, 50%, 0.5, or just .5, you do lose information regarding the total possible outcomes in simplifying fractions. However, it can be more informative to say 20% when saying "rolling a 16+ on a d20," though. Unless you're in a probability class, the way you present your answer won't matter.

The probability of an event E happening is written as P({E}). This is always a number between 0 and 1 (including 1 and 0). If you get something other than a number between 0 and 1, you're doing something wrong.

Inverse/What are the odds of something not happening?

If you're looking at a situation where something will either happen or not happen, then the odds of something not happening are equal to one minus the odds of it happening. So, the odds of rolling a 6 on a d6 is 1/6. The odds of not rolling one is 5/6. Add those together, you get 6/6, or 1. A lot of the time it's easier to work out the odds of something not happening and take the Inverse than to work out the odds of something happening.

Compound/What are the odds of several things happening?

The probability of any mutually exclusive events happening is the sum of the probabilities of each event. That is, since you cannot simultaneously roll a 1, 2, or 3 on a d6, they are mutually exclusive events. The probability of rolling a 1, 2 or 3 on a d6 is P({1})+P({2})+P({3})=1/6+1/6+1/6=3/6.

For multiple events happening in a specific order over multiple trials, (for instance, the odds of rolling a d20 and getting four natural twenties in a row) take all the odds and multiply them together. So, the odds of rolling one natural twenty is 1/20. Two in a row? That's 1*1 / 20*20, or 1/400. Three in a row? 1/8000. Four? 1/160000. Getting a 9 on a d10 and then getting a 75 or higher on a d100 is 1/10*25/100 or 25/1000 or 1/40.

What does that mean for your chances of rolling a nat 20 if you just rolled one? Absolutely fucking nothing. Your dice don't remember what you just rolled, and if they did they wouldn't care. This is known as the Lack of Memory property, and is obvious from each event (roll) being independent. In notation, it would be P({20}|{20}), or "the probability of rolling a 20, given that a 20 has already been rolled."

Keep in mind that this is NOT the same as saying "rolling a d20 two times and getting at least one natural 20." The probability of this happening is actually 9.75%. Why? See below.

Combination of Two/What are the odds of at least one thing happening in a set of two?

You're trying out DnD 5e, and you learn about its fancy new Advantage mechanic, where you can roll two d20s and take the higher of the two. If your rogue has advantage and needs a 9+ on a d20 to hit, what is the chance you're going to need to test out your new boots of frantically running away?

Calculating this rogue's chances is a matter of combining the rules we've looked at above. To get the expected number of hits we can just add the chances from each d20: P({rolling 9+ on a d20})=.6, so we would expect 2*.6=1.2 successes, and if we wanted expected damage we could stop there.

However, this is clearly bullshit, because the rogue can't hit twice on one attack. To compensate for this, we subtract the chance of getting 9+ on both rolls. This gives us the real formula we want: P({success}) + P({success}) - P({success})*P({success}). This rogue, then, is looking at a .6+.6-.36=.84 chance to hit, or only a 16% chance to miss that crucial backstab.

We can get to this probability in a number of other ways, too. The simplest might be one minus the chance that neither attack hits. We know that's the product of the two miss rates, so this works out to 1-( P({miss}) * P({miss}) ), or 1-(.4*.4)=.84. Convenient.

To check, we could alternatively look at the three mutually exclusive ways we could succeed this attack. The rogue could A: hit on both dice, B: hit on the first but miss the second, or C: hit on the second but miss the first. For the numbers: P(A)=.6*.6=.36, P(B)=.6*.4=.24, P(C)=.6*.4=.24, this P(A)+P(B)+P(C) = .36+.24+.24 = .86 . We're now pretty sure we know the rogue's success rate, and are ready with the fleeing boots for that 16% failure chance.

Complex combinations/What are the odds of a specific number of things happening?

Having saved the rogue, we now go to 40k. We have a squad of ten tactical marines firing bolters into 3 plague zombies that we really need cleared off a victory point. For those that stumbled in here without knowing 40k (welcome to /tg!), each marine needs to roll several d6s to take out a zombie. First, they need 3+ on a d6 to hit, then 3+ on a d6 to wound, then the zombie needs to fail a 5+ Feel No Pain roll. What are the chances those tac marines will wipe out the zombies? Should we point a valuable squad of assault marines at them for support?

This is going to have an easy part and a hard one. The easy part is the chance of one marine killing one zombie. A d6 has a 4/6 chance of getting a 3+, and also a 4/6 chance of missing a 5+. This marine, then, has a 4/6 * 4/6 * 4/6 = 64/216 = 8/27 = 29% chance to clip a zombie from the group. We've got ten marines, so our 'expected' number of dead zombies is 10*.29, or 2.9, just a little under the three we want. That suggests we should probably call up the assault marines, as there's a good chance we won't clear that whole group out.

Now, the tricky part. This is a really close game, and those assault marines are desperately needed elsewhere. We want the exact possibility the plague zombies won't survive. Open up Wolfram Alpha, and buckle up. Skip to the TL;DR if you just want a highly useful formula for mathhammering.

We have ten marines and we're looking to put at least three unsaved wounds downrange, so we're looking for the number of ways to score precisely 3 successes in 10 tests. To make matters a little worse, we actually also need the number of ways to score 4 successes, or 5, or 6, or more, up to ten. Inflicting more wounds is not a problem for us. To work this out, we'll need the probability for a given scenario of hits, and the number of ways that scenario can occur.

Let's look at inflicting exactly one wound. This requires one marine to succeed and all the others to fail. If we said that marine were the first guy in the squad we could tell how likely that is by multiplying everything together. We know the first marine succeeds and all the others fail, so this is P(success)*P(failure)*P(failure)*P(failure)*etc... one success and nine fails, in that order. P(failure) is just 1-P(success), so we've got .29 and .71.

The probability of any scenario like this, then, is just P(success)^{number of successes} * P(failure)^{number of failures}, or in this case, .29*.71*.71*.71*.71*.71*.71*.71*.71*.71 = .29*.71^9 = .29*.0458 = .0133. Wow, it sure got tedious in here. So, this 1.3% chance is the chance of scoring exactly one kill in exactly this way.

We know there ten scenarios exactly like this one, differing only in which marine got the kill. We don't care about the difference, so those ten scenarios with 1.33% each give us 10*.0133 = .133, or a 13.3% chance to kill exactly one zombie.

Now we can compute the possibility of any given scenario, but to inflict two wounds we would need to know how many ways you can organize two successes out of ten tests. Same thing for three, or four, or whatever else. For one success in ten tests, that was easy. For two or more, it's really annoying. Fortunately, we have this function on our calculators fittingly called a 'Combination':

Simply put, a Combination is the number of ways an event can occur in a set, ignoring order. This is important to us because we don't care what order these wounds are inflicted in and we don't want to spend all day multiplying numbers (only most of the day). A Combination combines two numbers, the number of test and the number of successes.

I'm going to call the number of tests T and the number of successes S. The Combination of T and S is written 'T choose S', or TcS.

For the curious, the internal math on a Combination:

Know what a factorial is? In math, the exclamation point pulls double duty both as a point of excitement and also as notation for 'multiply this number by everything below it'. 5!, for example, is 5*4*3*2*1. Everyone learns about them in middle school, then nobody ever uses them. ...until now.

TcS = T! / (S! * (T-S)! )

So, 10C3 = 10! / (3! * 7!) = (10*9*8*7*6*5*4*3*2*1)/((3*2*1)*(7*6*5*4*3*2*1)). Cool thing is, the sequence 7*6*5*4*3*2*1 will always show up in the numerator and the denominator. We can cross it right off.

10C3 = (10*9*8)/(3*2*1). Way better. Even by hand it's not too hard to get to 120. However, we didn't get to be the dominant species on the planet by doing things the hard way. Just make Wolfram Alpha do it: [1]

For the less curious, 10c3 = Make WolframAlpha do it: 120.


Alright, we've got our tool. Back on track. Ten marines, three zombies. The probability of any scenario that delivers S wounds from T marines with a per-marine kill rate of P is P^S*(1-P)^(T-S). There are TcS ways for that scenario to occur. We're down to the good stuff:

Probability of inflicting exactly S wounds = TcS * P^S*(1-P)^(T-S)

Exactly three wounds, ten marines, three zombies? 10c3 * (.29^3)*(.71^(10-3)). Wolfram Alpha, away! 26.6%

Ever so close. That's the chance of exactly three unsaved wounds. We would be fine with four, or five, or any other number above three. So we need to either add up everything above S=3, or add the results for zero, one, and two wounds and subtract that from one. 59% chance. This game is going to be close, but the marines are more likely than not to win.

TL;DR The general form of all this is that if you have a number of tries T each with a success rate of P, the chance of getting exactly S successes is TcS * (P^S)*((1-P)^(T-S)). If you're looking for at least S successes, add the results of this formula for everything between S and T. Or, if you're a real human with things to do, make a machine do it.

This is pretty easy to modify. Just change the inputs a little bit to try things out. Marines are rapid firing? Plague zombies are normal cultists? Eight devastators firing S8 AP3 krak missiles at a T6 3+ Carnifex with 5+ cover? Enjoy.

Rolling for successes/hits

Relevant for: Shadowrun, old WoD, new WoD, others

What are the odds of me succeeding with X many dice?

You can work out the chances of every individual result, but the quickest way to figure out if you're going to get any successes at all is to take the Inverse of rolling no successes at all.

So, you've got 4d10 and you need an 8, 9 or 10 to succeed? You've got a .3 chance of a success on one die, meaning you have a .7 chance a failure on one. You're rolling four dice, so the odds of all of them being failures is .7^4, or 0.7*0.7*0.7*0.7, or 0.2401. The inverse of that, the odds of getting anything other than zero successes, is 0.7599.

Incidentally, if you're working with that Target Number 8 in the last paragraph and you want a quick way to work out your chance of success... The odds of failing outright with two dice are 0.49, or about 1/2. That means the odds of failing with four dice are about 1/4. Six dice gives you 1/8, eight gets you 1/16, or 15/16 chance of getting at least one success. Repeat as many times as you like.

There are tables floating around, but I cannot into embedding images. http://wiki.white-wolf.com/exalted/index.php?title=Dice_Probability/Heroic,_TN_7

General Polyhedral Dice

Relevant for: Dungeons and Dragons

What are the odds that dX beats dY?

Want to know if a d6 is going to beat a d12? First, there are 72 ways this could come out (6 times 12, from the two dice), so the answer will be X/72. Next, look at it this way:

If the d12 lands on a 6 or higher, then the d6 will not be higher than it. If it lands on a 5, then one of the results on the d6, the 6, would be higher than it. So that's 1/72 so far. If it lands on a 4 then there are two results, if it lands on a 1 then there are five. There's a total of 1+2+3+4+5 results that would make the d6 the higher die, 15 in total. The odds of a d6 being higher than a d12 are 15/72.

d10 vs d12? That's 9+8+etc / 10*12, so 45/120.

What are the odds that adX beats bdY?

step 1: AdX (sum the results) yields a number between A (when you roll all ones) and A*X (when you roll all X's (i.e. 6's). The trick here is that there are more results than sums, and so you need to work out how often these sums occur for your results.

lets look at 2d6 : there are 36 unique unique combinations of 1 through 6 (taken twice)

2 can occur 1 way (1/36)
3 can occur 2 ways (2/36)
4 can occur 3 ways (3/36)
5 can occur 4 ways (4/36)
6 can occur 5 ways (5/36)
7 can occur 6 ways (6/36)
8 can occur 5 ways (5/36)
9 can occur 4 ways (4/36)
10 can occur 3 ways (3/36)
11 can occur 2 ways (2/36)
12 can occur 1 way (1/36)

lets look at the corresponding 2d10: there are 100 unique combinations of 1 through 10 (taken twice) these can sum up to

2 can occur 1 way (1/100)
3 can occur 2 ways (2/100)
4 can occur 3 ways (3/100)
5 can occur 4 ways (4/100)
6 can occur 5 ways (5/100)
7 can occur 6 ways (6/100)
8 can occur 7 ways (7/100)
9 can occur 8 ways (8/100)
10 can occur 9 ways (9/100)
11 can occur 8 ways (8/100)
12 can occur 7 ways (7/100)
13-20 can occur 36 ways (36/100)

So for 2d6 to beat 2d10:
one way is 2d6 =3 and 2d10 = 2 (2/36)*(1/100)
one way is 2d6 =4 and 2d10 = 2 (3/36)*(1/100) or one way is 2d6 =4 and 2d10 = 3 (3/36)*(2/100)
one way is 2d6 =5 and 2d10 = 2 (4/36)*(1/100) or one way is 2d6 =5 and 2d10 = 3 (4/36)*(2/100)or one way is 2d6 =5 and 2d10 = 4 (4/36)*(3/100)

add up all the results and you have your answer!