]> git.sesse.net Git - foosball/commitdiff
Oops, also remember the C++ part of the assessment.
authorSteinar H. Gunderson <sesse@debian.org>
Fri, 5 Oct 2007 16:45:39 +0000 (18:45 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Fri, 5 Oct 2007 16:45:39 +0000 (18:45 +0200)
foorank.cpp

index 080798caec02676ecb649982b36595c4e28ef15f..3ad0bb1ea725203b402c3ee8fd438e084c7bcb0e 100644 (file)
@@ -373,10 +373,29 @@ int main(int argc, char **argv)
        double sigma1 = atof(argv[2]);
        double mu2 = atof(argv[3]);
        double sigma2 = atof(argv[4]);
-       int score1 = atoi(argv[5]);
-       int score2 = atoi(argv[6]);
-       double mu, sigma;
-       compute_new_rating(mu1, sigma1, mu2, sigma2, score1, score2, mu, sigma);
-       printf("%f %f\n", mu, sigma);
+
+       if (argc > 5) {
+               int score1 = atoi(argv[5]);
+               int score2 = atoi(argv[6]);
+               double mu, sigma;
+               compute_new_rating(mu1, sigma1, mu2, sigma2, score1, score2, mu, sigma);
+               printf("%f %f\n", mu, sigma);
+       } else {
+               // assess all possible scores
+               for (int i = 0; i <= 9; ++i) {
+                       double newmu1, newmu2, newsigma1, newsigma2;
+                       compute_new_rating(mu1, sigma1, mu2, sigma2, 10, i, newmu1, newsigma1);
+                       compute_new_rating(mu2, sigma2, mu1, sigma1, i, 10, newmu2, newsigma2);
+                       printf("10-%u,%f,%+f,%+f\n",
+                               i, prob_score(i, mu1-mu2), newmu1-mu1, newmu2-mu2);
+               }
+               for (int i = 10; i --> 0; ) {
+                       double newmu1, newmu2, newsigma1, newsigma2;
+                       compute_new_rating(mu1, sigma1, mu2, sigma2, i, 10, newmu1, newsigma1);
+                       compute_new_rating(mu2, sigma2, mu1, sigma1, 10, i, newmu2, newsigma2);
+                       printf("%u-10,%f,%+f,%+f\n",
+                               i, prob_score(i, mu2-mu1), newmu1-mu1, newmu2-mu2);
+               }
+       }
 }