goete111 / factorie

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

Incorrect initialization of ds in MaximizeBetaByMomentMatching #31

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In cc.factorie.generative.MaximizeBetaByMomentMatching: Initializing ds as...

val ds = new cc.factorie.util.ArrayDoubleSeq(childFactors.size)

means that ds gets initialized (essentially) as an array with a single element 
set to the number of factors (i.e. Array(100.0)).  The intent is to build an 
ArrayDoubleSeq of *size* childFactors.size (or to initialize a buffer to that 
size, maybe?) and fill each element with values to be computed.  With its 
current initialization, the initial element is incorrect, and the array can't 
grow when we try to add a new element (I get a run-time array out-of-bounds 
error when trying to add a second element).

As a temporary fix, I changed the line on my machine to...

val ds = new cc.factorie.util.ArrayDoubleSeq( new 
Array[Double](childFactors.size) )

However, I'm not sure if that's how you mean for ArrayDoubleSeq variables to be 
initialized in general.

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