X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bayeswf.cpp;fp=bayeswf.cpp;h=71686c999cb944f2af6226d23b9fcf7e07d9115e;hb=3755fe5fbb4bafc3a0b32de691b7c287af91886a;hp=7ee0120a592e23f1075ebef4cfc1a7cb36fbec47;hpb=7868d20e3a8cad6c589298f7163357bea97a6b3e;p=wloh diff --git a/bayeswf.cpp b/bayeswf.cpp index 7ee0120..71686c9 100644 --- a/bayeswf.cpp +++ b/bayeswf.cpp @@ -201,6 +201,9 @@ void construct_hessian(const float *mu, int num_players) { memset(hessian, 0, sizeof(hessian)); + for (int i = 0; i < num_players; ++i) { + hessian[i][i] += 1.0f / (prior_sigma * prior_sigma); + } for (unsigned i = 0; i < all_matches.size(); ++i) { const match &m = all_matches[i]; @@ -224,6 +227,14 @@ void compute_mu_uncertainty(const float *mu, int num_players) { memset(mu_stddev, 0, sizeof(mu_stddev)); + // Temporarily use mu_stddev to store the diagonal of the Hessian. + + // Prior. + for (int i = 0; i < num_players; ++i) { + mu_stddev[i] += 1.0f / (prior_sigma * prior_sigma); + } + + // Matches. for (unsigned i = 0; i < all_matches.size(); ++i) { const match &m = all_matches[i]; @@ -233,10 +244,11 @@ void compute_mu_uncertainty(const float *mu, int num_players) double sigma_sq = global_sigma * global_sigma; float w = m.weight; - // Temporarily use mu_stddev to store the diagonal of the Hessian. mu_stddev[p1] += w / sigma_sq; mu_stddev[p2] += w / sigma_sq; } + + // Now convert to standard deviation. for (int i = 0; i < num_players; ++i) { mu_stddev[i] = 1.0f / sqrt(mu_stddev[i]); }