I've been looking for a way to compare two values, and every idea I think of falls short in some way. Essentially, I want a function $f$ that meets these conditions for non-negative scalars $x, y$:
If $x = 1000$ and $y = 1100$, $f(x,y)$ is not significantly large.
If $x = 0$ and $y = 1$, $f(x,y)$ is not significantly large.
If $x = 100$ and $y = 300$, $f(x,y)$ is significantly large.
If $x = 0$ and $y = 100$, $f(x,y)$ is significantly large.
Possible options I've considered:
- $f(x,y) = x-y$
- $f(x,y) = \frac{x-y}{min(x,y)}$
- $f(x,y) = \frac{x-y}{(x+y)/2}$
- $f(x,y) = \frac{x-y}{max(min(x,y),1)}$
Problems with each option:
- $f(6000,6100)$ = $f(100,0)$
- Division by zero
- $f(1,0) = f(100,0)$
- This is the best option I've considered, and is often how K/D ratios are calculated in video games. Still, it feels odd and I believe that there exists a better solution.
Some other properties of my mythical function $f$:
$f(x,y) = -f(y,x)$
$f(x,x) = 0$
I realize I have not been precise with the values I want $f$ to return, but $f(x,y)$ should essentially be the answer to the question "how big is the difference between $x$ and $y$?"
To give an example (and my current use case): I want to compare the usage of words between two texts of similar size. Obviously, "and" will be used a lot by both texts, and one may use it hundreds of times more than the other, but it is overall insignificant. Similarly, one text may use one rare word once while the other doesn't, but this too is insignificant. However, if one text uses a certain word far more often than the other text, this is statistically significant, just like if one text uses a rare word multiple times.