goete111 / factorie

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

Inference with PlatedDiscreteMixture.Factor #33

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In MaximizeProportions.maxProportions() (ProportionsVariable.scala), there 
appear to be two errors in the case that matches factors to 
PlatedDiscreteMixture.Factor.  The original code is...

case pdm:PlatedDiscreteMixture.Factor => {
        // We don't yet handle variational summary of PlatedDiscreteMixture.Factor
        val mixtureIndex = pdm._2.indexOf(e)
        var i = 0; val len = pdm._1.length
        while (i < len) { if (pdm._3.intValue(i) == mixtureIndex) e.+=(pdm._3.intValue(i), 1.0); i += 1 }
      }
    }
    e
  }

Fix #1...

The line "val mixtureIndex = pdm._2.indexOf(e)" is trying to determine the 
index of the mixture component that corresponds to the the proportions variable 
that we're optimizing (that is, p), as opposed to the temporary variable that 
we set up to accumulate the result (e).  It should read (I think)...

val mixtureIndex = pdm._2.indexOf(p)

Fix #2...

The line "e.+=(pdm._3.intValue(i), 1.0)" is trying to accumulate the counts 
corresponding to the states of the observed variable, which should be pdm._1, 
as opposed to pdm._3, which is the state of the gate variable for that observed 
node.  It should read (again, I think)...

e.+=(pdm._1.intValue(i), 1.0)

Original issue reported on code.google.com by mark.fry...@gmail.com on 7 Nov 2012 at 5:49