How does the spreadsheet mathematical model work?
If you love maths and want the hard stuff, all the detailed principles are explained in this article.
For the sake of simplicity, let's just look at a basic example:
Simple example
a, b, c = 3 different tf2 items for which we want to know the refined value.
r = refined = 1, that's our base currency
Let's say we found the following trades
2*a + b was exchanged for c + r
b + c was exchanged for 5*a
a + c + 2*r was exchanged for b + 4*r
Since r = 1, we can find the equilibrium by rewriting the trades in the following equation:
2*a + b - c = 1
-5*a + b + c = 0
a - b + c = 2
Solving this linear system of equations, we find that:
a = 1
b = 2
c = 3
This example was simple since we had as many trades as items, so we could find a perfect equilibrium.
Important Note that buying/selling has no meaning, we could change all the signs (by multiplying each line by -1) and the solution would be exactly the same. This holds true in the more advanced example.
A more advanced example
Now let's get to the realistic case were there are more trades than items.
Important Note that in reality there's a factor of 200 times (or more) trades than items for statistical significance.
For the sake of simplicity, we'll solve this problem on L2 (e.g. not using L1 median mathematics, for that refer to the article linked above).
2*a + b was exchanged for c + r
b + c was exchanged for 5*a
a + c + 2*r was exchanged for b + 4*r
a + b + c was exchanged for 6.33*r
We have an overdetermined system, and since we're solving on L2, the goal now is to find the solution to:
Solve a, b, c that minimizes e0 + e1 + e2 + e3 for:
(2*a + b - c - 1)2 = e0
(-5*a + b + c - 0)2 = e1
(a - b + c - 2)2 = e2
(a + b + c - 6.33)2 = e3
Solving this system produces the values:
a = 1.0440
b = 2.1155
c = 3.1375
Important This example demonstrates overdetermined solving on L2 for the sake of simplicity. In reality we use L1, refer to this article for full details.
Why using L1 (median) rather L2 (average) ?
What are the effects of norms:
- L2 norm is very easy to solve, however it's very sensitive to outliers (e.g. trades where the difference of value is huge whatever the reason, be it due to scamming, alt-account transfer, giving to friends, or any other reason).
- The best norm of all be would L0, maximizing the number of 0-equations (equilibriums), however L0 is not computable in polynomial time (NP-complete problem).
- L1 is the next best norm, it can be computed efficiently with recent advances in mathematics and it's much much less sensitive to outliers than L2.
So effectively, solving an overdetermined system (with more trades than items) on L1 retrieves the median prices of items.
Example:
median(2, 3, 10, 4, 3, 3.5, 2.5) = 3
average(2, 3, 10, 4, 3, 3.5, 2.5) = 4
It's easy to see that the big outlier value (10 in this example) has no impact on the median, if we were to replace it by 100, the median value would still 3 while the average would be 16.85 !