r/CompetitiveHS • u/skeptimist • Mar 21 '16
Article Is your sample size too small? Part 1
Is Your Sample Size Too Small? Part 1
As the Hearthstone player base becomes more competitive and technology develops, third-party software for tracking win-loss statistics has become increasingly popular. This proliferation of statistics within the Hearthstone community has naturally led to these statistics being presented in discourse within Competitive Hearthstone social circles, often by people with limited statistics experience. Win-loss statistics can be a powerful analytical tool if used properly, however people that present their matchup statistics often do so without statistically significant results or are met with criticisms that the sample size is “too small” without any mathematical proof provided.
Unfortunately, there is no “one size fits all” method for evaluating the significance of your sample size, as different questions require different amounts of statistical rigor. This is the first of (hopefully) many guides to show some statistical methods that can be used to answer general types of questions related to win-loss statistics in Hearthstone. This guide focuses on specific matchup results, since metagame considerations are too important for determining win rates against the entire field and add an additional layer of complexity.
Perhaps the most useful aspect of this article is the development of a “back-of-the-envelope” method for calculating proper sample size for deck matchups. I hope to develop more useful equations for other scenarios in future articles, such as for testing whether two sets of match-up data agree and whether one deck is better than another deck in a certain matchup.
The Nature of Win-Loss Data in Hearthstone
Although ties are technically possible in Hearthstone, the vast majority of games played result in either a loss or a win. Although there are a number of useful metrics by which decks and card choices can be evaluated, producing more wins is the ultimate goal of any card or deck choice and is therefore the most commonly used statistic in competitive Hearthstone.
Since ties can be considered negligible, game data can reasonably be described as binary with a win being counted as a 1 and a loss recorded as a 0 in a sample set. A distribution that can only take on two values is known as a Bernoulli Distribution, especially when those results can be described as either a success or failure. Since the “true” win percentage of any matchup considers every possible occurrence and every game played (past, present, and future), the population size is essentially uncountable and can therefore be approximated as infinite. Your win-rate statistics ultimately represent a small sampling of this infinite population. Notably, the “win-rate” of a deck against another according to your statistics is technically the sample mean of your sample set.
Bernoulli Distributions are most useful when the probability of success p is known, however the true matchup percentage of Hearthstone decks is obfuscated by a variety of factors, including deck construction and tech choices, good and bad draws, play skill, and RNG elements. It is important to minimize these factors as much as possible to obtain reliable data. Ways to minimize each of these sources of sampling error are described in detail below.
Minimizing Sources of Sampling Error
Tech choices and Deck Construction
Try to ensure that your opponent is playing a list as close to stock as possible. If you get blown out by an off-beat tech choice it is likely correct to remove the game from your sample set. The same is true if your opponent plays sub-optimal cards. Unfortunately, tech choices are difficult to account for completely. For example, the difference between one and two Ironbeak Owls in the Zoo vs Freeze Mage matchup is drastic, but you may only see one Owl in the game as Freeze Mage so it won’t always be clear for your statistics.
RNG
There is some level of RNG in nearly every deck due to cards with random outcomes. In general, the best way to deal with this is to remove games with extreme game-losing RNG like Doomsayer coming out of Shredder at the perfect time. Another example would be dealing lethal with an RNG-based card like Crackle. If you have to roll that 6 to win the game then it might be correct to only count it as a 0.25 in your stats. Aside from extreme examples like this, it is usually best to just include the games in your sample and perhaps multiply your required sample size based on the amount of RNG in the deck. Perhaps I will address this more thoroughly in another article, because it is a difficult topic to cover in a short paragraph.
Skill Level Mismatch
This is difficult to recognize if it doesn’t involve overt misplays, but in general the best way to minimize this is to count games played between rank 5 and Legend. Each player should assess their own skill level to determine their individual threshold for counting games in the sample.
Play Errors
It can be difficult to detect your opponent’s mistakes, but if you make a game-losing, obvious mistake (not just a “do they have it?” type of 50/50 choice) then it is probably correct to omit it from your sample set.
Confidence Interval
The Confidence Interval (CI) describes the range of values in which the true population mean exists with a certain probability. The 95% confidence interval (the most commonly used) therefore represents the range of values which is 95% likely to contain the true population mean (i.e. the true matchup win-rate p). It is usually described using the sample mean plus or minus a certain value (known as the margin of error E). For the sake of simplicity, the equations described below will assume a 95% confidence level is always desired, but the margin of error might be different for different applications. For example, determining the true matchup percentage of two decks requires more statistical rigor than simply determining which deck is favored. In the first case, we might want a margin of error of plus or minus 5 percentage points, or even plus or minus 1 percentage point. On the other hand, determining who is favored in a matchup might require a margin of error of plus or minus 25 percentage points.
It is also important to recognize that we will sometimes have a rough idea of the win-rate we can expect to get from a matchup. For matchups between new decks or unsolved matchups, we might not have a good idea about the true win rate between the decks in question.
What is the “True” Win-Rate of Deck A against Deck C?
The approximate number of games (sample size n) needed to accurately determine the win-rate p of a matchup with 95% confidence can be estimated based on the desired margin of error E and the estimated win-rate p*:
n = p* (1-p*)(z/E)2
z is calculated based on the desired confidence interval. For the 95% confidence interval, z = 1.96 but 2 is a reasonable approximation to allow this to be done as a back-of-the-envelope calculation. Notably, more lopsided matchups require fewer games to accurately verify win-rate than more closely contested matchups due to the shape of the p* (1-p*) curve.
Unfortunately, the tester doesn’t always have a reasonable estimate of the win rate going into testing. In this case, the maximum sample size needed is determined by assuming that the matchup is 50/50. As it turns out, this is a reasonable assumption unless the matchup is quite lopsided (75/25) because p* (1-p* ) is fairly stable near the middle of the range. For an even matchup p* (1-p* ) conveniently simplifies to ¼. Since (1.96)2 is approximately 4, these two terms cancel out. As such, here is the “back-of-the-envelope” method for calculating proper sample size:
n = 1/ E2
Yes, it is ultimately pretty simple given the assumptions we have developed. The difficulty is playing enough games, as illustrated below.
For E = 0.25, n = 16
For E = 0.05, n = 400
For E = 0.01, n = 10,000
Improving precision of your estimate requires exponentially more games the more precise you want to be. It requires few games to determine who is generally favored in a matchup but a huge number of games to determine the matchup within 1 percentage point of error.
That is everything for today. If I get a good response from this article I will try to address other questions and scenarios every other week, so please give me your feedback!
Sources:
http://www.measuringu.com/blog/what-test.php
Dunlop, Dorothy D., and Ajit C. Tamhane. Statistics and data analysis: from elementary to intermediate. Prentice Hall, 2000.
40
u/JimboHS Mar 21 '16 edited Mar 22 '16
A million times this.
Can we please just require people to post confidence intervals along with their win rates on this sub? I'm really tired of seeing people claiming 70% WR over something like 50 games.
The formula for 95% confidence is approximately:
interval = p ± 2*sqrt(p * (1-p) / n)where
nis the number of games andpis the win rate.For the above example, that works out to a 95% lower bound of just 57%.
EDIT: here's a link that does the plug and chug: https://www.wolframalpha.com/input/?i=p+%C2%B1+2sqrt(p++(1-p)+%2F+n),+where+p%3D0.72+and+n%3D68
6
u/sirbruce Mar 21 '16
Unfortunately no one person is going to play 400 games with one deck just to determine how good it is, so we have to rely on other measures. But while these measures are not as precise, it doesn't mean they aren't useful.
3
u/Dashiel_Bad_Horse Mar 21 '16
What are the units on E? For example, N = 16, E = 0.25 = 25% margin of error on the win-rate?
8
u/minased Mar 22 '16
Great post. One thing I would say is that I'd caution against excluding 'outlier' results caused by RNG/misplays etc.
This is partly because it's hard to know where to draw the line - if you need to topdeck one card to win and you do, do you exclude that game? What if you need to draw any of 4 cards out of 16 in your deck (same odds as rolling 6 on a Crackle)? The other problem is that it introduces a risk of cherry-picking - even with good intentions people will struggle to keep these exclusions completely impartial.
In general, it's better to accept these outliers as part of the dataset and trust that they will even out in the long run.
4
u/Respecs Mar 21 '16
Yeah, this is a helpful reminder. I know all these stats but sometimes get lazy about it.
We don't need people calculating and sharing confidence intervals with all posts. But posting actual W/L for each matchup vs. a % is definitely a must.
1
u/thenamestsam Mar 21 '16
Nice work on this. I also think it's potentially worth mentioning the value of Bayesian statistics as well, although I'm not the one to write a full post about it. We all have fairly strong priors about various elements of Hearthstone even before testing(just look at any of the card reveal threads), and in a lot of cases those priors can be pretty valuable since samples (particularly in certain deck matchups) are often quite small. It's helpful to understand how our priors can impact our understanding of small sample size statistics.
For example, lets say I'm testing some new control warrior list. I may only have ten games in my sample vs. freeze mage, but because I have such a strong prior that this is a very favorable matchup I would be quite confident reporting it as such even if the n is obviously very small. Now I probably can't say with any precision whether it's an 80-20 matchup or 90-10, but a lot of times in HS that may not be the most important distinction. On the other hand if I reported that the deck was strongly favored against midrange Druid on the basis of a ten game sample you'd be rightly much more skeptical because that violates your priors that Druid is a touch matchup for control warrior.
Basically what I'm saying is not all small sample claims are created exactly equally.
1
u/PasDeDeux Mar 23 '16
You know this and phrased it appropriately further up in the post, but I'm just clarifying for everyone:
A 99% confidence interval means that the real population mean is 99% likely to fall within that interval. Say we get a 99% interval of 0.5 to 0.9.
That doesn't mean that you expect 99% of players to have a win-rate between 0.5 and 0.9. It means that you expect the average of all of those players to fall within that range, which could conceivably be as low as 0.5, meaning that some players would even have "negative" win rates, or as high as 0.9 meaning it could potentially be unbeatable for the players on the high-side of that average.
1
u/LustHawk Mar 24 '16
Can someone explain CI in laymans terms?
3
u/fropome Mar 22 '16
There's a bigger issue than confidence intervals (though that's a valid point). That is, the samples used for the stats are not representative of the population of games that you will play. There are of a number of reasons for this, eg:
I work in economic/social stats, and I'm much less worried about the maths here than the sampling etc. Don't worry about spurious accuracy, just know that the win-rate of a deck will usually be higher than you'll manage with the same deck.
1
u/Insamity Mar 21 '16
I think most sciences are moving toward a 99% confidence interval since 95% isn't rigorous enough.
2
u/Xzirezhs Mar 23 '16 edited Mar 23 '16
This should be a sticky. Finally someone made a post on win rates. I am annoyed by all the people claiming a 80% win rate. It's not possible to have an 80% win rate over a sufficent sample size due to to the nature of ladder. The game will put you up against people that are of the same skill level which means your overall win rate should never peak above 70% considering how many players play the game. I also think it would be nice if u made this easier to understand. English is my second language and despite having worked with probability I had to read the post twice to make sure I didn't misunderstand. This might just be that I personally lack the English field terminology(don't know if this is the right word), but i feel like none nativ English speakers will have a hard time. Some of the sentences are on a pretty high level in terms of the English it self.
2
u/ilikevws Mar 24 '16
As a casual Hearthstone player that just discovered the game a couple of weeks ago..
What. The fuck. Did I just read.
1
u/Madouc Mar 22 '16 edited Mar 22 '16
Great Post!
My problem is, that i will never have enough time to play the game long enough to come to a suitable sample size, and i also often swap decks or alter my decks before that point.
So i have to rely on those skilled guide writers, and i hope they take your thoughts in account for future guides with winrates.
Anyway, nice read, some more time on the 'usefully spent' side of the books, thanks for that!
EDIT: One question remains: How do you reflect the Ladder Rank in your sample size? Given every player has his skill limit, and let's assume this is somewhere between rank 5-1 you might have a lot of wins early season when climbing up but then the curve flatens out and is approxing the true win rate, or maybe if you have come over your target rank (where you belong because of your personal skill) due to a luck streak your win rate falls apart before it goes up towards your real rate again.
1
u/asynk Mar 22 '16
Related: Here's a post I made where I ran a Monte Carlo simulation to frame "how many games to legend?"
https://www.reddit.com/r/hearthstone/comments/3cgnm7/how_many_games_does_it_take_to_reach_legend_a/
1
u/CoolzInferno Mar 23 '16
I agree that Win-Rates should be treated as qualitative descriptors and not hard quantitative stats. Because of the amount of uncontrollable variables (player skill; RNG; misplays; everything mentioned in this article) around winrates, I don't feel like "true winrates" are something that can be practicably calculated.
If you were to put in some kind of data pool system, it'd also rely on all the people entering the data using the same format and system... which would be subject to error.
Coming from a competitive Fighting Game background, Tiers are often defined around matchup strengths and generally around comparisons of toolsets and how characters' tools matchup with one another rather than off hard quantitative data, because again there are so many variables, decision making and intangibles...
It'd be completely erroneous to say "I went 8-2 as Zoo vs TempoMage#80percentWinRate" but the general consensus is that it's a favourable matchup for Zoo based on their tools and gameplans of each deck. I'd call that a 60-40 matchup just based on my own qualitative judgment.
Comparatively, the most obvious super-skewed matchup is Control Warrior vs Freeze Mage and that'd be closer to an 8-2 matchup, if not worse as so many things have to go JUSSST right for the Freezemage to have any chance of actually winning.
Adding complex statistical analysis is a great pipedream, but I question if its something that would be of great value. If I'm looking at a guide, I'd personally prefer a breakdown of a matchup. Something like:
Control Warrior v Oil Rogue [7-3 Favoured]. Rogue has limited minions to put pressure on control warrior. Warrior's ability to armor up and lack of reliance on creating board presence makes it very challenging for Oil Rogue to generate a win condition.
IF there was X-hundred or thousand games extra of stats to say CW v Rogue (75.423% win rate, 95% CI 65-85, n = 400), I don't really know if that would be of a great practical benefit in me trying to learn or understand a class or a matchup?
1
u/jackofools Apr 16 '16
This should be in the subreddit's wiki. Excellent guide!
1
u/Colin10112 Mar 22 '16
I'm a high school senior who spends most of my AP Statistics class playing hearthstone. I never would of thought that they'd be put together like this. Great post though, I'm learning about confidence intervals right now so this is a cool way to look at it.
0
u/[deleted] Mar 21 '16
[deleted] — view deleted comment