use utf8;
use locale;
require '../config.pm';
+require '../common.pm';
my $cgi = CGI->new;
}
sub make_table {
- my ($lowest_division, $used_ratings, $used_ratings_stddev) = @_;
+ my ($lowest_division, $used_ratings, $used_cov) = @_;
print <<"EOF";
printf MCCALC "%d\n", scalar keys %players;
for my $id (keys %players) {
- my $rating = $used_ratings->{$id} // 1500.0;
- my $rating_stddev = $used_ratings_stddev->{$id} // $parms{-3};
- printf MCCALC "%s %f %f\n", $id, $rating, $rating_stddev;
+ my $rating = $used_ratings->{$id} // 500.0;
+ printf MCCALC "%s %f\n", $id, $rating;
+ }
+
+ # covariance matrix
+ for my $id1 (keys %players) {
+ for my $id2 (keys %players) {
+ if ($id1 == $id2) {
+ printf MCCALC "%f ", ($used_cov->{$id1}{$id2} // $parms{-3});
+ } else {
+ printf MCCALC "%f ", ($used_cov->{$id1}{$id2} // 0.0);
+ }
+ }
+ printf MCCALC "\n";
}
for my $match (@matches) {
chomp;
my @x = split /\s+/;
my $id = $x[0];
- my $player = sprintf "%s (%.0f ± %.0f)", $players{$id}, ($ratings{$id} // 1500.0), ($ratings_stddev{$id} // $parms{-3});
+ my $player = sprintf "%s (%.0f ± %.0f)", $players{$id}, ($ratings{$id} // 500.0), ($ratings_stddev{$id} // $parms{-3});
$prob{$player} = [ @x[1..$#x] ];
}
close MCCALC;
}
$q->finish;
+# Pick up covariance matrix
+my $player_sql = '{' . join(',', keys %players ) . '}';
+my $q = $dbh->prepare('SELECT * FROM covariance WHERE player1=ANY(?::smallint[]) AND player2=ANY(?::smallint[])', { pg_prepare_now => 0 });
+$q->execute($player_sql, $player_sql);
+
+my $cov = {};
+while (my $ref = $q->fetchrow_hashref) {
+ $cov->{$ref->{'player1'}}{$ref->{'player2'}} = $ref->{'cov'};
+}
+
my $lowest_division = ($division == $max_division);
make_table($lowest_division, {}, {});
se <a href="/rating">ratingsiden</a>.</p>
EOF
-make_table($lowest_division, \%ratings, \%ratings_stddev);
+make_table($lowest_division, \%ratings, $cov);
-print << "EOF";
+wloh_common::output_last_sync($dbh);
+
+print <<"EOF";
</body>
</html>
EOF