+
+ if (output_mode == PROBABILITY_MATRIX) {
+ for (int j = 0; j < num_players; ++j) {
+ ++placements[stats[j].player_index][j];
+ }
+ }
+ if (output_mode == MOST_LIKELY_MATCHING) {
+ if (stats[match_position].player_index != match_player_num) {
+ continue;
+ }
+
+ // compute the log-likelihood of this situation (ignoring the constant terms)
+ double llh = 0.0f;
+
+ // strength of all players (ignore the constant terms)
+ for (int p = 0; p < num_players; ++p) {
+ llh -= drawn_normals(p) * drawn_normals(p) * 0.5f;
+ }
+
+ // all the matches
+ for (int pl1 = 0; pl1 < num_players; ++pl1) {
+ for (int pl2 = pl1 + 1; pl2 < num_players; ++pl2) {
+ if (has_scores[pl1][pl2]) {
+ continue;
+ }
+ float mu = drawn_ratings(pl1) - drawn_ratings(pl2);
+ float z = (scores[pl1][pl2] - scores[pl2][pl1] - mu) / match_stddev;
+ llh -= z * z * 0.5f;
+ }
+ }
+
+ if (!has_mlm || llh > mlm_likelihood) {
+ has_mlm = true;
+ mlm_likelihood = llh;
+ memcpy(mlm_scores, scores, sizeof(mlm_scores));
+ }