From: Steinar H. Gunderson
Date: Wed, 30 May 2012 19:32:34 +0000 (+0200)
Subject: Make rating.pl use the common function for fetching aux parms.
X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=44b0ccfdd1c79b013c72d1a6f71e3bc421f14186;p=wloh
Make rating.pl use the common function for fetching aux parms.
---
diff --git a/www/rating.pl b/www/rating.pl
index 40e9165..f69b19a 100755
--- a/www/rating.pl
+++ b/www/rating.pl
@@ -20,19 +20,13 @@ $dbh->{RaiseError} = 1;
binmode STDOUT, ':utf8';
-# Find auxillary parameters.
-my %params = ();
-my $q = $dbh->prepare('SELECT * FROM ratings WHERE id < 0');
-$q->execute;
-while (my $ref = $q->fetchrow_hashref) {
- $params{$ref->{'id'}} = $ref->{'rating'};
-}
-my $match_stddev = $params{-2} * sqrt(2.0);
+my $aux_parms = wloh_common::get_auxillary_parameters($dbh);
+my $match_stddev = $aux_parms->{'score_stddev'} * sqrt(2.0);
print CGI->header(-type=>'text/html; charset=utf-8', -expires=>'+5m');
POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8');
-printf <<"EOF", $params{-3}, $match_stddev;
+printf <<"EOF", $aux_parms->{'rating_prior_stddev'}, $match_stddev;
forklaring beregnet på ikke-matematikere.
- - MLE-basert modell med én skalar (styrke) per spiller og to globale skalarer (begge standardavvik, se under), løst med syklisk MM (minorization-maximization). Antall iterasjoner før konvergens: $params{-1}.
+ - MLE-basert modell med én skalar (styrke) per spiller og to globale skalarer (begge standardavvik, se under), løst med syklisk MM (minorization-maximization). Antall iterasjoner før konvergens: $aux_parms->{num_iterations}.
- Rimelighetfunksjon, prior: Normalfordeling med µ=500, σ=%.1f (est.)
- Rimelighetfunksjon, per kamp: Normalfordeling med µ=(score1 - score2), σ=%.1f (est.)
- Vekting: Inneværende sesong samt de tre siste vektes fullt ut
@@ -90,7 +84,7 @@ my $season = wloh_common::get_max_season($dbh, $locale);
# Pick up all the subdivisions' ratings.
my %subdivision_ratings = ();
-$q = $dbh->prepare('SELECT divisjon, avdeling, serie_id, AVG(rating) AS avg_rating FROM ratings NATURAL JOIN siste_divisjon WHERE sesong=? GROUP BY divisjon, avdeling, serie_id ORDER BY divisjon, avdeling');
+my $q = $dbh->prepare('SELECT divisjon, avdeling, serie_id, AVG(rating) AS avg_rating FROM ratings NATURAL JOIN siste_divisjon WHERE sesong=? GROUP BY divisjon, avdeling, serie_id ORDER BY divisjon, avdeling');
$q->execute($season);
while (my $ref = $q->fetchrow_hashref) {
@@ -170,6 +164,4 @@ print <<"EOF";