Tuesday, December 9, 2014

Mathhammer is a Dirty Word

If you go on any 40k forum or most 40k blogs you will hear people talk about 'mathhammer'.  People claiming Unit X is really good, or really bad because "Math!"  As I have mentioned previously I have a passion for math; in fact, it is my profession.  I am the person that gives people nightmares for years.  Thats right, I am a high school math teacher.

I am here to set the record straight about probability in warhammer.

*note: despite all my knowledge of mathematics I am still hold beliefs in 'Dice Voodoo'.  Sometimes I will only roll on a certain parts of the board, or only roll certain colors of dice.*

First off this is not statistics, unless you are recording exactly how a unit performs against every opponent, this is probability.  Theoretical probability is used to determine how likely certain actions are before they have taken place.

Expected Value: How most people 'do mathhammer'

Expected value is a term that you will see thrown around quite often.  More accurately it can be described as the average over a really long period of time.  It is calculated by multiplying the chance  of something happening with the 'value' of the result.  For instance the expected value of rolling a single die is 3.5 because



This leads to the first issue with expected value.  It is not actually possible to roll a 3.5.  Expected value is part of continuous probability where every value (even decimals) is possible. With dice rolls we are actually working with discreet probability (more on that later).

Expected value does have importance in warhammer; when I am in the middle of a game I will often calculate expected value to gauge whether I am rolling above or below average.  It is also important to note that the average value seen is most likely to approach the expected value when you roll more dice.  For instance a group of 30 orks is more likely to roll close to their expected value than a group of 5 space marines.  The smaller group is more likely to experience 'spikes' of good or bad luck.

This method is also problematic when working out estimates dealing with destroying vehicles.  As I said previously you have to multiply the chance of occurrence with 'value' of the result.  Hull points are very easy to calculate, they simply have a value of one.  When a vehicle explodes things are trickier.  If we assume that an 'explodes' result counts at three hull points (or the maximum number of hull points) then we are going to be overestimating the expected value since a vehicle with fewer than its maximum number of hull points would have a lower 'value' for an 'explodes' result.

The second issue is 'The Gambler's Fallacy'.  This is the belief that all probabilities must eventually approach the average.  It is true that the expected value is the most likely outcome; however previous dice rolls do not affect (or predict) future dice rolls.  If you are rolling poorly it is just as likely that you continue to roll poorly as you are to roll well.

Discrete Probability:

Discrete probability only deals with values that are actually possible.  The type of information you get is also fundamentally different that that of expected values.  With discreet probability you are generally looking at your chances that something will happen or not happen.

For instance, if you need to make a 9" charge you don't really care that the expected value of your charge range is 7"; you want to know your chances of actually making your charge (about 28%).  In this situation there are only two options: you make the charge, or you don't make the charge.  There is no in-between, so continuous probability does not make a whole lot of sense in this situation.

The downside to calculating this type of probability is that it is generally more difficult than expected value.  The probabilities of compound events generally can be calculated in your head (I certainly can't).

When I am theory crafting I like to use discreet probability because I generally have the time to work it out.  I may be thinking about a situation days, weeks, or even months before it might actually come up.

Expected value can be very helpful for estimating situations at a moments notice.  Often times I will calculate the expected value of wounds when I have two particularly tough targets to shoot.  This model is not always helpful especially when you are in an "all or nothing" situation such as making a charge.  When this is the case discreet probability will give a better representation of the situation than expected value.

Now you know.

*PS: If anyone is curious on the probability of a particular situation, or interested in learning how to calculate probabilities for yourself I would be happy to explain.*


  1. My head just exploded! :D

    Cool article. I am impressed you are able to work out your averages in the middle of games. I will never use mathhammer in my games because I am
    A: lazy
    B: I usually play by rule of cool, so sod how the model performs, if it looks cool I will use it :)

    Although after reading this maybe I will give it a try

    1. Most of the calculations I do are relatively simple for instance this happened last week. I had a squad of marines with two plasma guns and I was trying to decide whether to shoot a jetbike farseer with a rerollable 2+ jink or a wraithknight.

      For the farseer I hit on 2/3 and I wound on 5/6 but only 1/36 gets through his save, so I estimate that to be 2/3 * 1/36 or 1/3 * 1/18 which is 1/54.

      For the wraithknight I still hit on 2/3 but now I only wound on 1/3 and he had a 4++ save from something meaning I would only get through 1/2 of his armor. Well 2/3 * 1/2 = 1/3 and 1/3 * 1/3 = 1/9.

      So thinking about this math for a moment I realized that even though the giant wraithknight looks scary I am about 6 times more likely to wound the wraithknight than the farseer.

  2. Wow, ask and you shall recieve :) I've been scouring the interwebs looking for 'how to' calculate probability of dice. So far I've only come up with single result chances, and this doens't help. I'm very much interested in learning how to calc probabilities. I try to calc basic chances in the field but some situations are not right and I'm not always sure on my math.

    For example. I wanna know what the chances are of succeeding in certain actions. Like wrecking a land raider when you assault with 9 screamers, or the same scenario but with prescience for re-rolls to hit. Stuff like that. So any math hammer you wanna blog about or post links to I'm interested :)

    1. This I can do. I'll start work on the calculations.

    2. When working with probability its always easiest to start with a single opportunity. For example, what are the chances that one attack from a Screamer will pen a Land Raider.
      *This will use probabilities of rolling 2 dice so look those up if you don't know them*
      The chance a Screamer hits a Land Raider that has moved is 2/3 (3+ roll). When using Lamprey's Bite a Screamer needs to roll a 10 in order to glance a Land Raider (which is good for 1 hull point) which has a 3/36 chance or an 11 or 12 to pen which has a 3/36 chance combined as well.
      Let's ignore explosions now (we'll come back to it). So what we will calculate is the probability that a single Lamprey attack either glances or pens (without exploding) a land raider. The math is as follows:
      2/3*(3/36+3/36*5/6) ~= 0.10185
      hit chance * glance/pen chance (no explode)

      So you have about a 10.19% chance to get a hullpoint with a single Lamprey's bite attack.
      Additionally if we look at just exploding, a single attack has a:
      2/3*(3/36*1/6) ~= 0.009259
      So you have a 0.93% chance to explode the land raider.

      Now you could use pythagorean's triangle to find the probabilities of wrecking/exploding a land raider with a given number of hull points being attacked by a given number of screamers.

      I could expound upon that here but I don't want to make this wall of text any larger than it already is and I bet Andrew is already hard at work going more in depth than I did and I don't want to step on his toes.

    3. I have an update with full calculations including the combinatorics from pascals triangle.

  3. This is a great article. I hope you keep producing content. I was following the 40k daemons blog and sad to see them go, but glad you decided to run your own blog.

  4. NOTE: I am Italian. It's difficult to me to write about this subject even in my language, because it's really complex, so please forgive my bad English. I hope the general meaning is understandable.

    Ok, I am writing here because this post is more about math than the other.
    I was trying to calculate how many Wyches are needed to have good chance (more then 50%) to defeat 3 MegaNobz with 2 weapon S8 x 4 attack each and a 2+ armour save.
    And I found that it's more complicated than I was expecting.
    I begin with trying to calculate the "expected value" On the charge a wych has 3 attaks, she hit 1/2 of the times, wound 2/6 (=1/3) of the times, and has a penetrating armour rate of 1/6. So apparently 1/ 6 *1/2*1/3= 1/36 so I would need 36 attaks to make one wound to the Meganoobz whit the Wyches. They have 3 attaks each so I would need 12 of them to put a wound on the MegaNobz. Right? I'm not sure. Rolling 3 times a different amount of dices, is different than rolling them all together, because the result of the first rolling has some influence on the second and the third rolling, (and the second influence the result of the third). I mean, if the result og the first rolling is 17 instead of 18, on the second rolling my expected value will be 17/3=5,67; but I cannot roll 5,67 dices, so because 5,67 is not enough to make 6 dices. So I will roll 5 dices, and they are not enough to reach the right number to have an expected value of 1 wound (5/6).
    On the other hand, if on the 1st roll I would have had 19 good result instead of 18, 19/3= 6,33, and that mean that I will roll the same 6 dices on the last roll, without any true advantage.
    So my math is wrong.

    Another problem can be: assuming that the result of the previous passage were right (they are not), I would need 24 wyches charging 3 Meganobz to have an expected value of 1 Meganobz dead on the first assault phase. There is place enough for 24 wyches to join the combat? This is a geometrical problem.... and maybe it's more easy to try it on the board than loose my mind on complex areas problems... But, we have to consider that there is a maximum number of "weak models" that can join the fight. Yes, maybe they can join later, when their mates will be slaughtered by the "strong units" they dared to fight... and this is another issue....

    Enough for today. My brain is smoking.
    If I find some brilliant ideas to solve the problem I will inform you. Bye!!!

    1. You have given me all kinds of fun things to think about. You are correct with the 1/36 chance of causing a single wound. I will start working on the rest of the calculations.

      The geometry of placing models is going to be tricky, but I love a good challenge.

  5. My thought of the week:
    we have 3 possible "groups" of results:
    - the "tie" result
    - the group "Orks" wins
    - the group "Wyches" wins

    We could call a "Tie" when the amount of the wound is the same for both groups (without whipping out any contender). Note that a fight that goes on more than 2 turns (4 assault phases) becomes automatically a tie, because at that point of the game the whole mach is about to end (assuming that is nearly impossible to assault on turn one, and is likely to assault on turn 2 or 3...)

    For the group Orks win, or wyches win we have to consider the possibility to make the opponent run away from the fighting and the consequent possibility of catching and destroy them before he fly away.
    then we have to consider the fact that to run away during the enemy turn it's a good thing ( we have the option of an extra turn of shooting , and one more attack each model for the charge bonus).
    So we can calculate the probability of make the opponent run away, making one more wound than he does to us.
    I will work on this.