]> git.sesse.net Git - wloh/commitdiff
Add an optional prior weight. Does not seem to give a much better model, though.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 18 Mar 2012 12:21:15 +0000 (13:21 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 18 Mar 2012 12:21:15 +0000 (13:21 +0100)
bayeswf.cpp

index 71f60871a578fb180d972c775d0a4a0ba9cb8749..136a382349ac1528abadf2e5d1f325c93992cb5b 100644 (file)
@@ -11,6 +11,7 @@
 using namespace std;
 
 #define PRIOR_MU 1500
+#define PRIOR_WEIGHT 1.0
 #define MAX_PLAYERS 4096
 #define DUMP_RAW 0
 
@@ -74,8 +75,8 @@ void update_mu(float *mu, float *sigma, int player_num, const vector<match> &mat
        // Prior.
        {
                float inv_sigma2 = 1.0f / (prior_sigma * prior_sigma);
-               nom += PRIOR_MU * inv_sigma2;
-               denom += inv_sigma2;
+               nom += PRIOR_WEIGHT * PRIOR_MU * inv_sigma2;
+               denom += PRIOR_WEIGHT * inv_sigma2;
        }
 
        // All matches.
@@ -212,6 +213,9 @@ void update_prior_sigma(float *mu, float *sigma, int num_players)
        }
 
        prior_sigma = sqrt(nom / denom);
+       if (!(prior_sigma > 40.0f)) {
+               prior_sigma = 40.0f;
+       }
 }
 
 /*