]> git.sesse.net Git - wloh/commitdiff
Add a prior, to smooth out the mu a bit.
authorSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Sat, 17 Mar 2012 13:02:27 +0000 (14:02 +0100)
committerSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Sat, 17 Mar 2012 13:02:27 +0000 (14:02 +0100)
bayeswf.cpp

index 8b144da34e3a40f966f29a4cc5f57e70637e67b5..176d3459e02d56baefd151702045662665c8c925 100644 (file)
@@ -10,6 +10,8 @@
 
 using namespace std;
 
+#define PRIOR_MU 1500
+#define PRIOR_SIGMA 100
 #define MAX_PLAYERS 4096
 
 float mu[MAX_PLAYERS];
@@ -67,6 +69,15 @@ void update_mu(float *mu, float *sigma, int player_num, const vector<match> &mat
        }
 
        float nom = 0.0f, denom = 0.0f;
+
+       // Prior.
+       {
+               float inv_sigma2 = 1.0f / (PRIOR_SIGMA * PRIOR_SIGMA);
+               nom += PRIOR_MU * inv_sigma2;
+               denom += inv_sigma2;
+       }
+
+       // All matches.
        for (unsigned i = 0; i < matches.size(); ++i) {
                float sigma1 = sigma[player_num];
                float sigma2 = sigma[matches[i].other_player];