Is Hearthstone’s Heroic Tavern Brawl worth it?

TL;DR: If you’re a scratch player, Heroic Tavern Brawl has a slightly higher expected value than purchasing an equivalent amount of packs in the store. However, it has far less value than purchasing the same number of packs via gold.

My little brothers introduced me to Blizzard’s Hearthstone about a year ago. It and Factorio are the only games I play these days. If you have no idea what I’m talking about, then click here.

Today, Blizzard announced a new week-long mode called Heroic Tavern Brawl. For an entrance fee of $9.99 (or 1,000 gold), players are allowed to construct a deck and play in a makeshift tournament until they achieve either 12 wins or 3 losses. The more you win, the better the rewards.

Is it worth playing? I crunch the numbers in this Excel Book and explain below the fold. If you download the file, you can customize the calculation to your own situation.

Continue reading →

Matrix Multiplication in Excel — Markov Chains

This post is part of the “Matrix Multiplication in Excel” series. It’s composed of a math introduction, a silly interlude and an interactive tutorial (you are here). By the end of the series, you’ll learn how to perform Markov Chain calculations, which are used in some damage calculations.

Now that we know some of the basics, I’m going to introduce a toy problem where one would use matrix multiplication, step through how to calculate it in Excel and then give an example used forensic economics.

Click here to download Matrix Multiplication.xlsx.

Scenario 1: Ping Pong Problem

Suppose two ping pong players (labelled left and right) are tied near the end of a game. In order to win, one of them has to have a two point lead. Suppose that, on any given volley, the left player has a 55% chance of winning.

The game can be thought of as having five states:

  1. (2,0) – The left player wins.
  2. (1,0) – The left player is winning by one.
  3. (0,0) – The game is tied.
  4. (0,1) – The right player is winning by one.
  5. (0,2) – The right player wins.

Graphically, the transitions between these states can be seen as follows.

ppFig1

The left player increases his score with the probability p(LW), in this case 55%. How do we calculate the probability that the left player wins? Continue reading →

The Sleeping Beauty Problem

sb

Image credit: http://yourpsychotherapist.deviantart.com/

There’s an old fairy tale from Probabilia. Like all good Probabilian fairy tales, it has fair coins, maidens and -y godmothers to save us from monsters.

Sleeping Beauty volunteered for an experiment. On Sunday night she went to bed. On Monday, a fair coin was flipped. If the coin comes up heads, then sleeping Beauty is woken on Tuesday. If the coin comes up tails, then Sleeping Beauty is woken on both Tuesday and Wednesday. Whenever she is woken up, she is given a drug that prevents her from forming any memories, so whether it’s Tuesday or Wednesday, it’ll feel like it’s the first time she’s woken up. On Thursday, the experiment ends, and she continues on her way.

Whenever she is awoken, Sleeping Beauty is asked “what is the probability the coin came up heads?”

If you were Sleeping Beauty, how would you answer?

That’s confusing, so click this picture to embiggen a diagram.

SB

There’s one school of thought, “the halfer position,” which claims that she should always answer 50%. That was her belief before the experiment, and she was given no new information on Tuesday or Wednesday morning. (See this paper by David Lewis, Trigger Warning: PDF). To guess anything other than 50% feels like getting something for nothing.

But in a very real way, the halfer position is very wrong. Two times out of three, the right answer will be tails. If Sleeping Beauty were to make bets about the outcome of the coin toss, she would lose money if she believed the halfer position, and if probability theory doesn’t help us win money, then what’s the point? Continue reading →

Predicting NFL Scores: A Bayesian Approach

With the 2013 football season behind us, I’ve been spending my weekends developing a Bayesian model of the NFL with my college friend and UT math phd candidate Chris White.

To generate a Bayesian model, one first comes up with a parametric model that could generate the observed data. For simple problems, one uses Bayes rule to calculate the probability of parameters equaling certain values given the observed data. For complicated models, this is an extremely complicated task, but there are some monte carlo methods, such as Gibbs Sampling, which produce satisfactory approximations of the actual distributions. There are R packages available that make Gibbs Sampling fun.

I want to touch on many of these topics later in more in-depth posts, but first, here’s some results.

As of the end of the 2013 regular season, this is how our model ranked the NFL teams.

NFL Fig 1

These are the mean estimates of our Bayesian model trained on the 2013 NFL regular season. Our model predicts that, on a neutral playing field, each team will score their oPower less their opponent’s dPower. The former is the mean of a poisson process and the latter is the mean of a normal distribution. Homefield advantage is worth an additional 3.5 net points, most of which comes from decreasing the visitor’s score.

So we predict the Rams would beat the Lions by a score of 27.4 to 25.8 on a neutral field. Since we know the underlying distributions, we can also calculate prediction intervals.

Here’s the same model trained on both the regular season and the post-season. The final column shows the change in total power.

NFL Fig 2

I have a list of ways I want to improve the model, but here’s where it stands now. Before next season, I want to have a handful of models whose predictions are weighted using a Bayesian factor.

I’m very excited about this project, and I’ll continue working on it for a while.

Using Game Theory to Predict if the U.S. will Bomb Syria

predatorDrone21I’m good at some things, and foreign policy isn’t one of them. I have no idea if Syria actually used chemical weapons, how the U.S. should respond to any potential attack or the probability of attacks spilling over into larger conflicts. I don’t understand Russia’s incentives or how they will react to any acts of aggression. However, I have created an excel book that calculates mixed strategy equilibria, and I will use this as a game theory example.

As a study, game theory uses mathematical models to predict the actions of rational decision-makers. The world is complex and noisy. If we want to know anything, we must make simplifying assumptions. People aren’t actually rational, but we can measure where they fail and model imperfect agents. A simpler first-pass is to assume they rationally maximize “utility” and assign utility to all possible outcomes.

As a simple model of the situation, let’s assume that the U.S. and Russia can either Waver or Stand Firm. Let’s assume they make this decision simultaneously and once. Their payoff is defined by the following table:

NASH1

As an example on how to read this, if both countries waver, then the U.S. will receive -20 utility and Russia will receive 40 utility. If the U.S. stands firm and Russia wavers, then Russia will receive a payoff of 0 and the U.S. will receive a payoff of 30.

All of these values are editable in the excel file attached below. These are subjective estimates that I admittedly just made up. A bit of reasoning on the choices I made.

  • I’ve assumed the U.S. wants to give Iran a strong example of what happens to countries that use WMD’s of any sort. This means the U.S. would rather stand firm than waver, assuming Russia would not escalate the conflict.
  • I’ve read speculation claiming Russia has an economic interest in keeping Assad in power, as his government has made it more difficult for Qatar to sell natural gas to Europe.
  • To make the solution more interesting, I made these payoffs asymmetrical.
  • I’ve made the outcome of both countries going to war large and negative under the assumption that even a proxy war in Syria would be very bad for both sides.

The first thing my workbook does is check to see if any strategies weakly dominate the other. A strategy weakly dominates another strategy if a strategy is always as good or better than the alternatives regardless of how the opponent plays. In this game, each country would rather stand firm if the other wavers or waver if the other stands firm, so no strategies dominate.

Next, the workbook looks for Nash equilibria. A Nash equilibrium is a situation where neither player would unilaterally change his position. In this case, there are two Nash equilibria at the top right and bottom left. In these boxes, neither player can improve their outcome by changing their strategy. The top right equilibrium is better for the U.S. and the bottom left is better for Russia. But which equilibrium will we likely end up in?

In this case, probably neither. The next thing my workbook does is, if no strategies weakly dominate each other, then it will solve for the mixed Nash equilibrium. A mixed strategy is when a player chooses a probability distribution across all possible strategies. In the mixed Nash equilibrium, each player chooses a distribution of strategies that leaves the opponent indifferent between their strategies. Feel free to play with the payoffs and watch as the mixed solution changes.

In this case, the U.S. will waver from conflict roughly 96 percent of the time and Russia will waver roughly 91 percent of the time. In equilibrium, Russia and the U.S. will fight over Syria less than half a percent of the time.

NASH2

The final sheet of the workbook analyzes the outcome for both players, including the expected value of the outcome. Based on this simplistic analysis, it looks like the U.S. will not bomb Syria and, even if it does, it is unlikely Russia will escalate the conflict. This is a good thing for the world’s total utility.

This analysis could be furthered by having the U.S. and Russia play several rounds where they choose to Waver or stand Firm. Any improved utility estimates are welcomed.

Here’s a link to the excel book that generated these reports. Of course, this workbook can be used in other contexts such as pricing decisions in a duopoly, figuring out how to make your roommate do the dishes, analyzing the read option, modeling evolutionary equilibria or solving your Game Theory homework.

Dice Rolls

In a Straussian attempt to prove personality is genetic, my little brother texted me the following math question:

So imagine we have a die of n sides. We roll the die until it rolls a 1, the number of times it is rolled is the output. But, after each roll, we give the die one less face. What does the distribution of outcomes look like?

When I come across problems like this, I like to answer the question intuitively before solving for the actual answer. My brother and I both guessed what the distribution looked like. We both thought there’d be a very low chance of n or 1 being returned, and a higher chance of a number in the middle being returned. I thought the mode of the distribution would be lower than him.

Perhaps because probability wasn’t beneficial in the anscestral environment, we were both wrong. The distribution is actually perfectly uniform. Elementary math will show that the probability of rolling the first few numbers is exactly the same:

\frac{1}{n} , \frac{n-1}{n} \frac{1}{n-1} , \frac{n-1}{n} \frac{n-2}{n-1} \frac{1}{n-2}

I tested this empirically and produced the following histogram.

Rplot02

Here’s the R Code that generated that:

##Run Parameters
sides <- 100
runs <- 100000

Simulation <- as.data.frame(matrix(data=0,nrow=sides,ncol=runs))
for (n in 1:sides){
Simulation[n,] <- floor(runif(runs,1,sides-n+2))
}

Simulation <- Simulation==1

Outcomes <- vector(mode="integer",length=runs)

for (n in 1:runs){
Outcomes[n] <- which.max(Simulation[,n])
}

hist(Outcomes,breaks=20)

Monday Math Problem #1: Expected Births

My colleague Max Lummis became a father over the weekend, so in order to wrap up the recent series of posts on expected value, here’s a birth-themed, three-part math problem for your Monday afternoon.

I’ll give a hat-tip to the person who introduced me to the problem after posting the solution in a few days. Feel free to reference Wolfram and the rules of expectations.

Suppose there’s parents that can have infinite children who really want a boy. They will have kids until they have a boy. The probability of any given child being a boy is 50 percent.

  1. What is the expected number of boys?
  2. What is the expected number of girls?
  3. What is the expected percentage of the children that will be girls?

The Rules of Expectations

As promised, here are some rules for working with expected values, first in words and then in math. All of these can be verified in excel. I’ll also include a list of things that are not rules for working with expectations. These are all especially relevant in valuation if you have multiple uncertain parameters you are combining through probabilities. These also come into play while making total rows at the bottom of complex schedules. Sometimes they won’t foot, and this post will help you understand why.

The expected value of a constant is a constant.

E[c] = c

The expected value of two random values is equal to the sum of the expected values.

E[X + Y] = E[X] + E[Y]

The expected value of a random variable times a constant is equal to the constant times the expected value of the random variable.

E[cX] = cE[X]

Please note that this doesn’t hold if c is not a constant.

E[XY] \neq E[X]E[Y]

Remember these rules, as you will be tested on them.

What is Expected Value?

A random variable is a value which takes different values with certain probabilities. Per math convention, random variables are capital letters while values random variables may equal have lower case letters. Deeper questions like “what is probability” may be addressed in a future post.

Suppose you have a random variable X that can take any of the following values:

rvX

Working through the first line, there is a 75\% chance that X will equal \$ 10. The product of these two figures, \$ 7.50 is known as a “partial expectation.” The sum of all partial expectations, \$ 13.50 is known as the expected value of X, or E[X].

For discrete random variables (which can take a finite number or countably infinite number of values), this is denoted.

E[X] = \sum_{i} p_i \cdot x_i

Where p_i is the probability of scenario i occurring, and x_i is the value of scenario i. Examples of discrete random variables include the number of days a stock will increase in a row, the number of deposits in a bank account in a month or the sum of two rolled dice. Note that the first two are theoretically infinite.

For continuous random variables (which can take an infinite number of values), expected value is denoted as:

E[X] = \int\limits_{-\infty}^{\infty} x \cdot f(x) dx

Where f(x) = P(X = x) (the probability X = x. Examples of continuous random variables include the earnings of a company, the dollar value of deposits in a month or the time until someone in a family flips over a Monopoly board. Note that the lattermost is only theoretically infinite.

So that’s a mathematical explanation of expected value. What’s an intuitive explanation?

The expected value of X is the weighted average of x across all possible scenarios where the weights are based on the probability of a scenario occurring. This isn’t strictly accurate for the continuous case (since the probability of any specific individual outcome occurring is zero), but the intuition still applies.

Expected values are important because if you simulate X an infinite number of times, then you will average a return of E[X]. This is important for valuation because if you believe a cash flow will be worth X, then you will break even in the long run if you pay E[X] for it. If you need to make a profit to compensate yourself for opportunity cost, then you will have to pay less than E[X].

In modern finance, diversification and securitization have made expected value an increasingly important concept since it is far easier to own a large number of assets. However, as far as valuation is concerned, it is worth pointing out that expected value is but the first “moment” that can be used to describe a distribution. Higher moments (such as variance, skewness and kurtosis) play an important role, especially in financial contexts when diversification is limited.

When valuing companies, it is standard practice to develop “best, worst, likely” scenarios and subjectively determine probabilities for each outcome. The company is then valued as the expected value of each of the three discounted cash flows. This is valid as long as the discount rate adequately covers the higher moment concerns I alluded to above.

Next, you can expect to see a post on the mathematical rules of working with expectations.