From 636272edbe5d170f25703b6f7d79ee394dd766a3 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 17 Mar 2012 14:02:27 +0100 Subject: [PATCH] Add a prior, to smooth out the mu a bit. --- bayeswf.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bayeswf.cpp b/bayeswf.cpp index 8b144da..176d345 100644 --- a/bayeswf.cpp +++ b/bayeswf.cpp @@ -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 &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]; -- 2.39.2