title: Calculation of probabilities in Naive Bayes in C#
body: <p>I'm working on a Naive Bayes solution for C# where there are two possible outcomes. I have found a small sample code but was wondering if anyone would be able to explain the last line.</p>
  
  <p>The analyzer is finding the probability a word belongs to 1 of two categories </p>
  
  <p><code>cat1count</code> is the number of words found in category 1 ( if the word is found 2 times in category 1 it would be 2 / total words in category 1) </p>
  
  <p><code>cat1total</code> = total number of words in category 1 </p>
  
  <p>as I understand it, <code>bw</code> is the probability the word is in category 1 and <code>gw</code> is the probability the word is in category 2 </p>
  
  <p><code>pw</code> and <code>fw</code> are where I start to get a bit lost. The full source code can be found <a href="http://github.com/joelmartinez/nBayes/blob/master/nBayes/Analyzer.cs" rel="nofollow">here</a>.</p>
  
  <pre><code>        float bw = cat1count / cat1total;
          float gw = cat2count / cat2total;
          float pw = ((bw) / ((bw) + (gw)));
          float
              s = 1f,
              x = .5f,
              n = cat1count + cat2count;
          float fw = ((s * x) + (n * pw)) / (s + n);
  </code></pre>
  
  <p>what is <code>fw</code>? I understand what <code>bw</code>, <code>gw</code>, and <code>pw</code> are.</p>