

Let’s talk about mu and p

THE BOOK OF leQ

CHAPTER 2: Speaking The Language

{Editor’s Note: This chapter went a bit longer than I initially intended, both in development time and in length. I hope you stick with it since I think there are some payoffs, both in this article and the ones to come. To make things easier, I broke it up into three distinct parts for your convenience: 1) an intro for those of you newer to statistics, 2) a history lesson for the curious among you, and 3) the actual content. I definitely recommend statistics beginners start at the beginning and work through the additional problems at the end of the article. If you’re already comfortable with probability math, you can skip to Part 3 and call it a day. Really, this is meant to be a resource for you so use it however you’d like or skip it entirely! Special thanks to LordOfWinter and freddyd339 for the peer review.



EDIT: Part 3 had an error in which I mislabeled the white and black objects (which also affected the math a bit), but it’s fixed now — thanks for catching that, /u/usaegetta2! }

I’ve always thought of statistics as a branch of math that was sometimes unintuitive. I mentioned this to a friend once and he responded, “more like sometimes intuitive”. He has a point: it does seem like this field, more than others, leads us towards some mental pitfalls or logical fallacies with relative ease. But how come? I’ve heard it said that people just aren’t wired for conditional probability, but there’s some evidence to say we’re actually pretty good at it…sometimes. If I had to guess the real reason, I’d say it’s because we’re inclined to forget that statistics is a numbers game in which each of us only catch a few rounds at a time. The individual snapshots we see aren’t always coherent with the rest of the album, and when that happens it can be easy to follow the wrong idea.



This is definitely noticeable in games like Keyforge that mix strategy with a healthy dose of chance. On average, if you and a friend of equal skill play with equally strong decks, you should each win about half of the time…so what does it mean when that’s considerably not the case? We tend to search for reasons why things don’t go the way we expect them to, even if those explanations are themselves improbable. Maybe you always draw cards in the wrong order or your decks are consistently worse than your friends’ because you’re cursed with tough luck. My playgroup likes to joke that none of us can pull good decks ourselves so we go through a ritual of buying them for each other. It’s funny when it works, but it often doesn’t. Whatever the superstition, it’s easy to get caught in the trappings of perceived patterns and unlucky streaks.



But let’s not dwell on those scenarios. Instead, I think it’s more valuable to figure out how and why things work the way they do. Maybe there are reasons why the improbable seems to happen more for some decks and/or players than it does for others. Or maybe the “improbably good” happens as often for each of us as the “improbably bad” and we just tend to linger on our misfortunes. There are a ton of ways to approach and dissect this problem, and many factors are in play here. Over the next few chapters, we’re going to explore some of them like card functions, deck properties, and strategic archetypes. But before we do, I think it makes the most sense to start at the foundation on which these concepts are built.



I still find it pretty amazing that we’ve developed an elegant language to describe a host of complex mechanisms ranging from subatomic particle energies to linguistic phenomena and — of course — card games.

Yeah, that’s fair

Statistics help us illustrate these complicated landscapes by establishing what we might think of as a basic color palette and set of shapes. In this article, we’ll start with one category of math’s sacred geometries known as probability distributions.

PART 1.



What are probability distributions? They’re a way for us to determine how likely an outcome is given a range of all possible outcomes.



Ok, I’ve lied already. What I’ve actually described is a probability mass function, the discrete version of a continuous probability distribution function. I know this seems pedantic, but bear with me here. Much like how someone can say “concrete” when they mean “cement”, it’s still important to know the distinction between both even if it doesn’t change the core message. In this case, I think it’s easier to understand the differences with a few examples.



The figure below is the spread, or distribution, of all the possible permutations for rolling two six-sided dice. I’m sure you’ve seen this before, but if you haven’t here’s a quick rundown:



Source

This chart shows that out of all the ways two dice can be rolled, it’s most likely that the sum of both dice equals seven. This doesn’t mean that sevens show up the majority (or even anywhere close to half) of the time. In fact, you would only expect to roll a seven 17 times out of 100. Why is this the case? It all has to do with the number of indistinguishable microstates that are possible in a set of events (see Chapter 1 for a bit more on this). In this example, the microstates represent the different sums of two dice. Out of the 36 permutations/microstates, six are indistinguishable in that they add up to seven.



The easiest way of thinking about this is that the greater the number of similar events, the more likely you are to experience one of them, all things being equal. Another thing you might notice is that these 36 permutations describe 11 distinct sums. This means that we can expect some variance in the results as there are plenty of other outcomes that don’t add to seven. So now say we roll two 12-sided die: we would have slightly more than twice as many distinct sums (by the way, we can call these macrostates), but it also means we’ve increased the variance of the distribution by having a wider spread of outcomes. As we increase the number of macrostates, we also observe a greater variance in the distribution. We’ll be visiting this idea a few times over the next few articles so don’t worry if it’s not immediately intuitive. The important takeaway here is that if you were to make a bet on an event happening, the chance of the bet falling in or out of your favor depends on how unique the event is.



Now suppose you try to roll a seven with two dice and decide to track how often this happens in real time — what do your results look like? They would follow a binomial distribution, a mathematical spread based on how likely an event will occur as well as the number attempts taken. Here’s what this distribution looks like for the 1/6th chance of rolling a seven with two dice over 300 trials.



Binomial Calculator

This is an example of a probability mass function, a spread of probabilities for all possible discrete values that represent the number of times an event can occur. If the events could somehow be continuous (where values between integers were valid and ends went to the infinities), we’d have an even “smoother” graph representing a probability distribution function. There are many other distributions like this that are fundamental to math, science, economics, and…really everything. In this chapter, we’ll explore the main probability distribution at the center of all good card games: the hypergeometric probability distribution.

PART 2.



Let’s scroll back in time to the 1600s. Until now, at least in the Western sphere of math history, there was only ever a geometric series to describe the sum of a string of numbers where each number is a multiple of the previous one. A geometric series looks something like this:

Also around this time, the Dutch physicist Christiaan Huygens published a book (translated version here) that asked the question, what are the chances of pulling three black and four white balls from a bag of eight black and four white balls? Given the manual nature of calculations back then, this wasn’t an easy problem to solve since it required doing a lot of exponent math by hand. On top of that, there weren’t many people who had the reputation of being patient enough to work through it and not make mistakes along the way. About half a century later, a mathematician named Abraham de Moivre published a solution using a hypergeometric series (the term meaning “over-geometric” and named so because the geometric series is a specific instance of this series) to lay the foundation for the hypergeometric probability distribution/mass functions.



This was a pretty big deal in the realm of math and science back then, especially in the the burgeoning field of statistics and probability. At the time, there was still a lot of mystery behind predicting certain odds, and the field was young enough that you could likely stump the local math talent by asking about the chances of, say, rolling eight six-sided die and getting two or more 1’s.



These days, we have tools like binomial and hypergeometric distributions to help predict the probabilities of specific events happening in games of chance. For events that are independent of the outcomes of prior events, the spread of observed results would follow a binomial distribution. In our dice example above, rolling a seven once doesn’t change the odds of you rolling another seven later so the math behind this distribution is pretty straightforward (although we won’t go into it here). But when you draw a card from a deck and don’t replace it, there is one less card in the deck of that color/suit/category, and that changes your odds for the next draw. The languages that describes the likelihood of events in this type of scenario is the hypergeometric probability mass function.



There are two ways to work through the math here, and one’s more practical than the other. Let’s start with the more complicated of the two since it’s the more interesting one to talk about and will still be helpful when we take the easy route later.

PART 3.



Suppose you have three black balls and four white balls: how many different ways can you order them? There are 7! configurations for which the sequence of the balls matters and each ball is individually distinct. However, since the three black balls can assume any order between them (as can the white balls) there are 3! repeated configurations due to the indistinguishable nature of the black balls each with 4! repeated configurations from the identical white balls. This means we only have:

This the mathematical equivalent to saying “7 choose 3”, also written as . We can think of this as if there are seven open spots to fill and we’re choosing any three of them to be the black balls in whatever order. The math inherently accounts for the white balls as well so everything looks groovy so far. Now say we put these balls in a bag and randomly pull out four — what are the chances we pull three black balls and one white ball?

We can apply some similar logic here to write an equation to describe this scenario [Note: this is not a formal proof for deriving this equation; however, it’s still helpful to find alternative ways to explain the different terms]. We are choosing three out of three black balls and one of out four white balls . This captures all possible configurations for this quantity of white and black balls. However, the total number of configurations for choosing any four balls out of the full seven is . If we divide these terms, we get our probability for this specific scenario. That math looks like this:

Generally, the probability of something showing up k times is:

Where,

N = Total number of items to choose from (population size)

n = Number of items drawn (sample size)

K = Total number of favorable items (successes in population)

k = Number of favorable items in sample (successes in sample)

If we change the question slightly and say, “what is the probability we get at most one black ball when drawing four?” In that case, we have to calculate and sum the probabilities of drawing one black ball and drawing zero black balls. This looks like:

There’s just one last component to add here. What happens if we have more than two categories of items to choose from? Say we add six red balls to the mixture, how does our math change? All we have to do is introduce another binomial coefficient to the equation. In other words, if we have a bag of 3 black balls, 4 white balls, and 6 red balls, the chances of drawing exactly 1 white ball in three draws is:



Where n b is the number of black balls that can possibly show up.

If that last part lost you, don’t worry — this is the multivariate version of the hypergeometric probability distribution and it can be a bit harder to mentally visualize compared to the univariate version from before. In fact, I would say it’s not productive to get into the general equation since it’s largely nonsensical to anyone who isn’t comfortable with summation notation. But as long as you have a decent grasp of why the math works out the way it does, we can use a few online tools to help us apply this to Keyforge. Here is one of the more well-known univariate hypergeometric calculators as well as a multivariate calculator made for the Magic: The Gathering community that will also work for us. We’ll be using both in the upcoming articles.

[NOTE: If you’d like to get more familiar with them in the meantime, I’ve put a few practice problems and solutions at the end of the article along with some additional resources on distribution functions.]

CONCLUSION



I’m sure you’re already brewing up ways to incorporate hypergeometric calculations into Keyforge, and I’m looking forward to diving into some of those applications in upcoming chapters, too. It’s always fun to revisit some old problems with new tools, but there’s always a risk of over-engineering solutions or being tempted by confirmation bias. Don’t get me wrong, I hope you use these calculators to better understand why your decks draw cards the way they do or even find new ones with more “optimal” quantities of specific cards, but optimization isn’t the only road here. In fact, I’d argue Keyforge is far too complex for us to name the best deck or strategy using any mix of optimization tools (barring any accidental design elements that would spark an errata). Within just three expansions, we’ve already learned and re-learned a lot about the cadence of a typical match. Even though some patterns are apparent, I’m a fan of taking the reserved approach on assessing what’s “good” when many variables are in play and the Algorithm itself seems to be somewhat fluid.

So then why bother with any of this? Internalizing the implications of statistics is really a no-lose situation. Either we find ways to squeeze out some extra advantage or we learn exactly how much of this game is out of our control. Our goal may be to learn how to become more consistent winners, but that also implies we’re not always going to win. In that case, we might as well take the lesson on how to be better losers as well. After all, you’re playing this game because you like taking the chance, right?

Stay tuned for the next chapter when we explore how different categories of cards come together to create a deck strategy.

Until next time, fellow Archons. Play, fight, and reap forth!

-Kav

————————–

————————–

Additional Resources



Practice Problems:

1. https://probabilityformula.org/hypergeometric-distribution-examples.html

2. https://stattrek.com/probability-distributions/hypergeometric.aspx



Extra Hypergeometric Distribution Reading:

1. Mean & Variance (also will be briefly covered in an upcoming article): http://www.math.ucsd.edu/~gptesler/186/slides/186_hypergeom_17-handout.pdf

2. DeMoivre’s The Doctorine of Chances (the problems and solutions start on the book’s Page 9): https://books.google.com/books?id=3EPac6QpbuMC&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false