feat: new metric

This commit is contained in:
TrèsAbhi committed 2024-06-17 14:10:22 -05:00
1 parent 83527fed7d
commit 5f7330271c
3 files changed
+74 -187

No files matched your search

+1
View File
@@ -171,6 +171,7 @@
"wargaming",
"webp",
"whitespaces",
"WHSS",
"winrate",
"wireframe",
"Woah",
-187
View File
@@ -1,187 +0,0 @@
![Neutrality Index](https://i.imgur.com/XcGy5rh.png 'Neutrality Index')
# BlitzKit Neutrality Index
> [!CAUTION]
> This is a working draft and is incomplete. Do not implement.
## Frequently Asked Questions
### Why BkNI over WN8?
BkNI addresses a lot of issues with WN8:
- WN8 incorporates win rate into the metric; a metric like this must be a correlate of win rate, not a dependent
- The weights and biases are not dynamic and their formulation is not transparent
- WN8 values do not asymptote under extreme conditions resulting in meaninglessly large or negative values
- WN8 has too many digits; it doesn't make sense to differentiate between players with sub-one-thousandth's worth of precision
### Why "BlitzKit" in "BkNI"?
I believe that BkNI is far too complex for other developers to even bother implementing so it will probably stay native to BlitzKit. However, anyone is welcome to use BkNI!
## Preface
The goal of this paper is to deliver a numerical metric for judging player performance by converging all statistics down to a single, easy-to-consume, human-readable value. This must be a mathematically elegant process that yields a reasonable number that asymptotes under extreme situations. More specifically, this value should equal 0, on average across all players and tanks. Extreme cases should be mapped onto the range $[-1, 1]$. To attain the human readable value, we will be transforming the raw metric to a scale of $[0, 2s]$ using $M=\operatorname{round}\left(sR+s\right)$ where $M$ is the resulting human-readable metric, $s = 100$ is an arbitrary scaling factor, and $R$ is the raw metric.
Wargaming provides cumulative statistics for players and tanks. The big idea is to average all provided statistics together to get one unified value. We will also incorporate other composite values based on these default statistics into the average. However, averaging this way poses two problems:
1. All statistics do not scale equally. For example, good players performing with 3,000 damage per battle could also attain a kill-to-death ratio of 3. But averaging them as-is would imply damage per battle has weight 1000 times that of the kill ratio. In other words, damage per battle would totally diminish the impact of kill ratios on the average. Hence, there’s a need for normalization. Normalization, in most cases, simply means dividing by the corresponding averages.
2. All statistics are not equally important. For example, dealing damage is arguably far more important than base capture; hence, it does not make sense to average them together. But this does not mean we totally discard this value as it does make an impact albeit very small. Instead, we will be incorporating weighted averages where the weights will be calculated through correlational analysis against win rate. Specifically, the weights of the statistics will be the corresponding correlation coefficient, r. One caveat to look out for is that r can be negative for statistics like damage received which must be minimized. Fortunately, negative weights are okay and make intuitive sense; after all, bleeding health should punish the metric.
## Computation
$\mu$ is a simple weighted average of statistics across all players where $C_{battles}$ is the number of player battles and $x_{i}$ is the statistic for player $i$.
$$
\mu=\frac{\sum C_{battles}x_{i}}{\sum C_{battles}}
$$
$\sigma$ is the standard deviation of the statistic across all players. Below is a refresher of the formula where $x_{i}$ is the statistic for player $i$ and $n$ is the number of players (or the sample size).
$$
\sigma=\sqrt{\frac{\sum \left(x_{i}-\mu\right)^{2}}{n}}
$$
A normalized atomic statistic is provided by the equation below where $x$ is the player's statistic being evaluated, $\mu$ is the mean of the statistic across all players, and $\sigma$ is the standard deviation of the statistic across all players. During computation, one may pre-compute and reuse $\gamma=x-\mu$.
$$
A=\frac{x-\mu}{\left|x-\mu\right|}\left(1-e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^{2}}\right)=\frac{\gamma}{\left|\gamma\right|}\left(1-e^{-\frac{1}{2}\left(\frac{\gamma}{\sigma}\right)^{2}}\right)
$$
$r$ is the correlation coefficient of the statistic across all players. Below is a refresher of the formula where $x_{i}$ is the statistic for player, $y_{i}$ is the player's win rate, $\mu$ is the mean of the statistic across all players, and $\overline{y}$ is the average win rate across all players.
$$
r=\frac{\sum \left(x_{i}-\mu\right)\left(y_{i}-\overline{y}\right)}{\sqrt{\sum \left(x_{i}-\mu\right)^{2}\sum \left(y_{i}-\overline{y}\right)^{2}}}
$$
$m$ is the slope of the least squares regression line. Below is a refresher of the formula where $x_i$ is the player's statistic being evaluated, $y_i$ is the player's win rate, and $n$ is the number of players (or the sample size).
$$
m=\frac{n\sum x_{i}y_{i}-\sum x_{i}\sum y_{i}}{n\sum x_{i}^{2}-\left(\sum x_{i}\right)^{2}}
$$
The weight of an atomic statistic is $w$ where $r$ is the correlation coefficient between the statistic and win rate, $\mu$ is the mean of the statistic across all players, and $m$ is the slope of the least squares regression line.
$$
w=\left|r\right|\mu m
$$
The raw metric is the weighted average of all atomic statistics.
$$
R=\frac{\sum wA}{\sum w}
$$
The final human-readable metric will be passed through the following transformation where $s=100$.
$$
M=\operatorname{round}\left(sR+s\right)
$$
## Constants
A few constants that the rest of the paper depends on. Available under the “constants” object.
```ts
players_per_team = 7;
```
## Wargaming-Provided Statistics
Wargaming provides the following pieces of statistics for each player and tank. These are cumulative; in other words, they simply add up over time and it is up to the recorder to contrast two snapshots of said statistics in time to get periodical statistics. Available under the “all” object.
```ts
battles;
capture_points;
damage_dealt;
damage_received;
dropped_capture_points;
frags; // kills
frags8p; // frags against tanks at or above tier 8
hits;
losses;
max_frags;
max_frags_tank_id;
max_xp;
max_xp_tank_id;
shots;
spotted;
survived_battles;
win_and_survived;
wins;
xp;
```
## Composite Statistics
Raw statistics from Wargaming can be combined into more meaningful numeric snippets. Most of these values are divided by all.battles indicating they are the average across all battles in the given period. Assigned under the “composite” object.
```ts
win_rate = all.wins / all.battles;
capture_points = all.capture_points / all.battles;
damage_dealt = all.damage_dealt / all.battles;
damage_received = all.damage_received / all.battles;
dropped_capture_points = all.dropped_capture_points / all.battles;
frags = all.frags / all.battles;
hits = all.hits / all.battles;
shots = all.shots / all.battles;
spotted = all.spotted / all.battles;
survival_rate = all.survived_battles / all.battles;
xp = all.xp / all.battles;
damage_ratio = all.damage_dealt / all.damage_received;
accuracy = all.hits / all.shots;
damage_per_hit = composite.damage_dealt / composite.hits;
```
## Normalized Statistics
We will be using the standard deviation and the mean of each metric supplied to this expression below to normalize each metric in the range $[-1, 1]$. The goal is to map the mean of the statistic to $0$, and the extrema to $-1$ and $1$ (whichever direction that may be in).
$$
\frac{x-\mu}{\left|x-\mu\right|}\left[1-e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^{2}}\right]
$$
During computation, one may pre-compute and reuse $\gamma=x-\mu$ in:
$$
\frac{\gamma}{\left|\gamma\right|}\left[1-e^{-\frac{1}{2}\left(\frac{\gamma}{\sigma}\right)^{2}}\right]
$$
Here is an example of HisRoyalFatness scoring a very high $0.988$ with the frags metric with his [XM551 Sheridan](https://blitzkit.app/tools/tankopedia/20257). $\mu=0.7694$, $\sigma=0.2492$, and $x=1.5113$, HisRoyalFatness' average frags. At $x = 0$ (if the player manages to get no frags), the metric drops nearly to $-1$ and vice versa. And, at $x=\mu$, the metric is exactly $0$.
![](https://i.imgur.com/aIUQmGF.png)
### Derivation
We start with the standard normal distribution formula
$$
\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^{2}}
$$
![](https://i.imgur.com/a10m8Xz.png)
We remove the coefficient to transform the range of the function from $\left(0,\frac{1}{\sigma\sqrt{2\pi}}\right]$ to $\left(0,1\right]$. From this point onwards, I will be using the substitution $\gamma=x-\mu$.
$$
e^{-\frac{1}{2}\left(\frac{\gamma}{\sigma}\right)^{2}}
$$
![](https://i.imgur.com/67DO69i.png)
Then we mirror the function across $y=\frac{1}{2}$ to allow the function to be rewarding as you reach the extrema.
$$
1-e^{-\frac{1}{2}\left(\frac{\gamma}{\sigma}\right)^{2}}
$$
![](https://i.imgur.com/1J0cTyb.png)
Finally, to punish the function as you approach the left extreme, we flip the sign of the function when $x<\mu$. One may choose to implement this as a piece-wise function (especially when implementing this in a computer), but I have chosen to represent it as one unified coefficient in this paper.
$$
\frac{\gamma}{\left|\gamma\right|}\left[1-e^{-\frac{1}{2}\left(\frac{\gamma}{\sigma}\right)^{2}}\right]
$$
![](https://i.imgur.com/O8stVlJ.png)
+73
View File
@@ -0,0 +1,73 @@
# Weighted Hyperbolic Standard Score (WHSS)
A next generation metric in judging player performance.
## Pre-requisites
This paper delves deep into mathematics and statistics which most may not be familiar with. You will need some basic understanding of normal distributions, correlation analysis, regressions, summation notation, hyperbolic trigonometric functions, and set builder notation.
## Preface
WHSS delivers a single, easy to consume number that measures the performance of a player independent to their winrate so that it is easy to judge their contribution to the team regardless of the performance of the other players in the team. This allows you to judge wether the player in question is "pulling their own weight."
The mathematics behind this metric has been intentionally generalized such that it isn't limited to just World of Tanks Blitz. You will be easily able to apply this metric in any other game/sport.
## Computation
The final metric, $M$, is an integer in the range $\left[0,200\right]$ where $100$ is the average score across all players, $0$ is "impossibly" bad, and $200$ is "impossible" good. The reason why I say "impossible" is because this scale is asymptotic. For example, it doesn't make sense to have a player to score $400$ which would imply they are $4$ times better than the average player in a linear scale. Though technically speaking, a score of $0$ or $200$ is asymptotic, rounding to the nearest integer allows for certain players to reach these scores.
$M$, the human-readable metric, is a function of $A$, the raw score in the range $\left(-1,1\right)$, where $C=100$ is an arbitrary scaling and offset factor.
$$
M=\operatorname{round}\left(CA+C\right)
$$
$A$ is the weighted average of all $a$ ("asymptotic scores" will be discussed later) with weights $w$.
$$
A=\frac{\sum wa}{\sum w}
$$
$w$, the weight of each asymptotic score, must be determined using $r$, the correlation coefficient, and $m$, the slope of regression line. Both of these values must be determined for each asymptotic scores through corelation analysis. Formulas for both will be discussed later. Here, $\left|r\right|$ represents the "confidence" of corelation and $m$ represents the actual corelation. $m$ is allowed to be negative such that asymptotic scores that actually harm the player's winrate will have a negative effect on the weighted average.
$$
w=\left|r\right|m
$$
$r$ is the corelation coefficient determined by analysis between the effect of $x_{i}$, any individual statistic like damage dealt normalized by the number of battles, against $y_{i}$, the wins also normalized by the number of battles. Normalizing this way makes $x_{i}$ the average of said statistics over all battles and $y_{i}$ the average winrate. Each player will have their own average $x_{i}$ and $y_{i}$ values which can be used to determine $r$. $n$ here is the number of players sampled to determine $r$.
$$
r=\frac{n\sum x_{i}y_{i}-\sum x_{i}\sum y_{i}}{\sqrt{\left(n\sum x_{i}^{2}-\left(\sum x_{i}\right)^{2}\right)\left(n\sum y_{i}^{2}-\left(\sum y_{i}\right)^{2}\right)}}
$$
$m$, in a similar fashion to $r$ can be computed using the slope of the regression line. In case you are wondering, the y-intercept $b$ of the regression line is a not required in our use case.
$$
m=\frac{n\sum x_{i}y_{i}-\sum x_{i}\sum y_{i}}{n\sum x_{i}^{2}-\left(\sum x_{i}\right)^{2}}
$$
Though not discussed yet, we will also be needing the two constants of a normal distribution. $\mu$ is the mean of the distribution.
$$
\mu=\frac{\sum x_{i}}{n}
$$
In a similar fashion, we will also need the standard deviation $\sigma$.
$$
\sigma=\sqrt{\frac{\sum \left(x_{i}-\mu\right)^{2}}{n}}
$$
Note that $r$, $m$, and $\mu$ use many of the same summations just in different places. During real computation, I would highly recommend pre-computing all the summations and deploying them to use to avoid excessive computation. This makes a world of difference when sampling hundreds of millions of players.
$a$ is the asymptotic score. An individual asymptotic score is a function of $z$, the standard score. We will be using the asymptotic scores for all available statistics except for the winrate to allow us to judge player performance based purely off their contribution to the team regardless of wether they win. $z$, as we will discuss next, is not asymptotic (it's possible for it to reach absurd, incomprehensible values that start to loose meaning in extreme cases); thus, the asymptotic score is simply a transformation of the standard score using hyperbolic tangent.
$$
a=\tanh z
$$
$z$ is the standard score which utilizes both the mean $\mu$ and standard deviation $\sigma$. $x$ here is the performance of the player we are trying to judge.
$$
z=\frac{x-\mu}{\sigma}
$$