commit 4cf7965e86a8e7128660791e6c2d80cbfa69ed6d
parent 8601ec34985dded1fea4ce5b750b33e21502187b
Author: Santtu Lakkala <inz@inz.fi>
Date: Thu, 12 Mar 2026 09:54:17 +0200
Regression towards the mean
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/simu.c b/simu.c
@@ -101,6 +101,7 @@ struct team {
unsigned games;
unsigned wins;
double elo;
+ double elo0;
long long unsigned pointsum;
long long unsigned gamessum;
size_t *poscounts;
@@ -545,8 +546,10 @@ int main(int argc, char **argv)
isort(teams, 1[&teams] - teams, sizeof(*teams), teampointscmp);
- for (i = 0; i < n; i++)
+ for (i = 0; i < n; i++) {
teammap[teams[i].id] = i;
+ teams[i].elo0 = teams[i].elo;
+ }
if (scanf(" %zu", &m) < 1)
return 1;
@@ -559,7 +562,10 @@ int main(int argc, char **argv)
return 1;
games[i].t[0] = teammap[h];
games[i].t[1] = teammap[a];
- games[i].expected = R_MAX / (1 + pow(10.0, (teams[games[i].t[1]].elo - (teams[games[i].t[0]].elo + homeadv)) / 400.0));
+ games[i].expected = R_MAX / (1 + pow(10.0, (teams[games[i].t[1]].elo - (teams[games[i].t[0]].elo + homeadv)) / 400.0));
+
+ teams[games[i].t[0]].elo += (2000 - teams[games[i].t[0]].elo) * elok / 200;
+ teams[games[i].t[1]].elo += (2000 - teams[games[i].t[1]].elo) * elok / 200;
}
if (threads > 1) {
@@ -606,7 +612,7 @@ int main(int argc, char **argv)
teams[i].games, teams[i].points,
teams[i].gamessum / iterations,
(double)teams[i].pointsum / iterations,
- (int)round(teams[i].elo));
+ (int)round(teams[i].elo0));
for (j = 0; j < n; j++) {
if (teams[i].poscounts[j] == iterations + 1)
printf(" +");