]> git.sesse.net Git - wloh/commitdiff
Take weight into account in Hessian.
authorSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Sat, 17 Mar 2012 01:30:45 +0000 (02:30 +0100)
committerSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Sat, 17 Mar 2012 01:30:45 +0000 (02:30 +0100)
bayeswf.cpp

index 56214b5494b5647fb718c63040ef29652fb5d4ca..b7abb59dddf4e806588a3f9c12de9acc4bb1999e 100644 (file)
@@ -163,8 +163,8 @@ void renormalize(float *mu, float *sigma, int num_players)
 /*
  * Compute Hessian matrix of the negative log-likelihood, ie. for each term in logL:
  *
- * M_ij = D_i D_j (- logL) = -1 / sigma²                                for i != j
- *                            1 / sigma²                                for i == j
+ * M_ij = D_i D_j (- logL) = -w / sigma²                                for i != j
+ *                            w / sigma²                                for i == j
  *
  * Note that this does not depend on mu or the margin at all.
  */
@@ -182,8 +182,10 @@ void construct_hessian(const float *mu, const float *sigma, int num_players)
                        double sigma2 = sigma[j];
                        double sigma_sq = sigma1 * sigma1 + sigma2 * sigma2;
 
-                       hessian[i][j] -= 1.0f / sigma_sq;
-                       hessian[i][i] += 1.0f / sigma_sq;
+                       float w = matches_for_player[i][k].weight;
+
+                       hessian[i][j] -= w / sigma_sq;
+                       hessian[i][i] += w / sigma_sq;
                }
        }