# Stochastic Extensions of the Elo Rating System
## Appendix C Implementation of the Rating System from SPI  
The SPI rating system that we used as a benchmark to compare our discrete model is described in [7,10]. The system uses two rating parameters for each team instead of only one, namely \(OFF_{A}\), which is higher the more goals team \(A\) is likely to score, and \(DEF_{A}\), which is higher the more goals \(A\) will allow its rivals to score.  
In a match between \(A\) and \(B\), in which \(A\) scores \(G_{A}\) goals and \(B\) scores \(G_{B}\), we define the Adjusted Goals Scored of \(A\) as  
\[AGS_{A}:=(G_{A}-DEF_{B})\frac{0.424\cdot AVG_{BASE}+0.548}{\max(0.25,0.424 \cdot DEF_{B}+0.548)}+AVG_{BASE} \tag{10}\]  
where \(AVG_{BASE}\) is the average number of goals scored by each team in a game. Similarly, the Average Goals Allowed of \(A\) is defined as  
\[AGA_{A}:=(G_{B}-OFF_{B})\frac{0.424\cdot AVG_{BASE}+0.548}{\max(0.25,0.424 \cdot OFF_{B}+0.548)}+AVG_{BASE} \tag{11}\]and both quantities are similarly defined for \(B\). The model then states that \(\mathbb{E}[AGS_{A}]=OFF_{A}\) and \(\mathbb{E}[AGA_{A}]=DEF_{A}\). From this, given some starting values for both parameters for both teams, we can infer \(AGS_{A}\), \(AGA_{A}\), \(AGS_{B}\), and \(AGA_{B}\) for each game, and correct the parameters by  
\[\begin{split} OFF_{A}^{\prime}&=\lambda AGS_{A}+(1- \lambda)OFF_{A}\qquad\qquad DEF_{A}^{\prime}=\lambda AGA_{A}+(1-\lambda)DEF_{A }\\ OFF_{B}^{\prime}&=\lambda AGS_{B}+(1-\lambda) OFF_{B}\qquad\qquad DEF_{B}^{\prime}=\lambda AGA_{B}+(1- \lambda)DEF_{B}\end{split} \tag{10}\]  
Since \(AGA_{A}\) and \(AGS_{A}\) are linear in \(G_{B}\) and \(G_{A}\), respectively, we obtain the expectation of \(G_{B}\) and \(G_{A}\) from them as follows:  
\[\mathbb{E}[G_{A}]=f_{A,B}:=(OFF_{A}-AVG_{BASE})\frac{\max(0.25,0.424\cdot DEF _{B}+0.548)}{0.424\cdot AVG_{BASE}+0.548}+DEF_{B} \tag{11}\]  
\[\mathbb{E}[G_{B}]=g_{B,A}:=(DEF_{A}-AVG_{BASE})\frac{\max(0.25,0.424\cdot OFF _{B}+0.548)}{0.424\cdot AVG_{BASE}+0.548}+OFF_{B} \tag{12}\]  
There are two issues with this: First, \(g_{A,B}\) and \(f_{B,A}\) should also match \(\mathbb{E}[G_{A}]\) and \(\mathbb{E}[G_{B}]\), respectively, but they do not necessarily match; in practice, we used \(\mathbb{E}[G_{A}]=\frac{f_{A,B}+g_{A,B}}{2}\) for estimating the win and draw odds in our code. The second issue is that the resulting value of \(\mathbb{E}[G_{A}]\) or \(\mathbb{E}[G_{B}]\) could be negative, and in that case, we impute \(10^{-6}\) as the expected goals of that team.  
Finally, in order to account for the home field advantage, supposing \(A\) and \(B\) play on \(A\)'s field, we modify the formulas above as follows:  
\[AGS_{A}:=(G_{A}-DEF_{B})\frac{0.424\cdot AVG_{BASE}+0.548}{\max(0.25,0.424 \cdot DEF_{B}+0.548)}+AVG_{AWAY} \tag{13}\]  
\[AGA_{A}:=(G_{B}-OFF_{B})\frac{0.424\cdot AVG_{BASE}+0.548}{\max(0.25,0.424 \cdot OFF_{B}+0.548)}+AVG_{HOME} \tag{14}\]  
where \(AVG_{HOME}\) is the average number of goals scored by home teams in our dataset, and \(AVG_{AWAY}\) the average goals scored by the visiting player.  
The formulas for \(f_{A,B}=(OFF_{A}-AVG_{AWAY})\frac{\max(0.25,0.424\cdot DEF_{B}+0.548)}{0.424 \cdot AVG_{BASE}+0.548}+DEF_{B}\), \(f_{B,A}\), \(g_{A,B}\), and \(g_{B,A}\) are modified accordingly.  
Finally, in order to use this model in the same dataset as the Elo system, we used the same algorithm as in Section 4.1 replacing the unbiased estimator for ratings by 50 iterations of the update formulas (10) from the arbitrary starting point \(OFF_{i}=DEF_{i}=1\), which quickly converged to a fixed point.  
The only parameter of the model is the update sensibility \(\lambda\) in (10), which plays a similar role as \(K\) does for the Elo system, and we also introduced a dampening parameter \(D\) so that the result predictions were calculated with \(D\cdot OFF_{A},D\cdot DEF_{A},D\cdot OFF_{B}\), and \(D\cdot DEF_{B}\) instead of the original parameters. In our training dataset for soccer, we found the minimum \(MSE\) at the point \(\lambda^{*}\approx\) 0.02 and \(D\approx\) 0.9.