X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bayeswf.cpp;h=f94b1d33f6e213f281fc308ad111ab06a69778ac;hb=c5cf5cb78785bfd57ea74b23d72ce4e27439ee2f;hp=a691b8fe915ac8f6bb8714e62bd2349c173201b1;hpb=35021b4f76156feb48fd9420a9116da50acee3e1;p=wloh diff --git a/bayeswf.cpp b/bayeswf.cpp index a691b8f..f94b1d3 100644 --- a/bayeswf.cpp +++ b/bayeswf.cpp @@ -227,13 +227,22 @@ void construct_hessian(const float *mu, int num_players) // Compute uncertainty (stddev) of mu estimates, which is sqrt((H^-1)_ii), // where H is the Hessian (see construct_hessian()). -void compute_mu_uncertainty(const float *mu, int num_players) +void compute_mu_uncertainty(const float *mu, const vector &players) { // FIXME: Use pseudoinverse if applicable. Matrix ih = hessian.inverse(); - for (int i = 0; i < num_players; ++i) { + for (unsigned i = 0; i < players.size(); ++i) { mu_stddev[i] = sqrt(ih(i, i)); } + + for (unsigned i = 0; i < players.size(); ++i) { + for (unsigned j = 0; j < players.size(); ++j) { + printf("covariance %s %s %f\n", + players[i].c_str(), + players[j].c_str(), + ih(i, j)); + } + } } int main(int argc, char **argv) @@ -340,7 +349,7 @@ int main(int argc, char **argv) dump_raw(mu, num_players); #else construct_hessian(mu, num_players); - compute_mu_uncertainty(mu, num_players); + compute_mu_uncertainty(mu, players); dump_scores(players, mu, mu_stddev, num_players); //fprintf(stderr, "Optimal sigma: %f (two-player: %f)\n", sigma[0], sigma[0] * sqrt(2.0f)); printf("%f 0 -2\n", global_sigma / sqrt(2.0f));