goete111 / factorie

Automatically exported from code.google.com/p/factorie
0 stars 0 forks source link

Sample Variance Computation Incorrect #30

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In cc.factorie.package.sampleVariance: Since this should return variance as 
opposed to standard deviation, we should not take the square root before 
returning.  Correction below...

  def sampleVariance(ds:cc.factorie.util.DoubleSeq, mean:Double): Double = {
    val len = ds.length; var i = 0
    var variance = 0.0
    while (i < len) {
      val diff = mean - ds(i)
      variance += diff * diff
      i += 1
    }
    // Since this is variance, we shouldn't take the square root -- MEF 10/23/2012
    //math.sqrt(variance / (len - 1))
    variance / (len - 1)
  }

Original issue reported on code.google.com by mark.fry...@gmail.com on 23 Oct 2012 at 2:10