Closed longouyang closed 9 years ago
While I think your suggestions are sane and would work, there's a more principled way to resolve this issue that might prevent bugs like this from popping up in the future. A random choice with a conditioned value really shouldn't be stored as a random choice in the inference routine (i.e. in the MH trace). Instead, it really should just be treated as a factor. That way, we don't have to deal with any special casing for "is this variable conditioned or not, can we propose to it, etc." All of that logic could be removed from the codebase.
In trying to implement this more principled fix, I came across two hurdles:
In the lieu of these hurdles, would it be okay if I committed the bandaid I proposed and add your more general fix to my todo list?
Huh. Item 2. is surprising; that'd be good to look into, eventually. Sure, I don't mind putting a bandaid on things for now :)
Okay, bandaid applied in af8358dc7cfe53b410a02c6c7cf19d17e2bdb017
A webchurch user found problems with this model:
This model tries to figure out whether the observation 10 came from N(-10,1) or N(10,1). The model should should strongly prefer N(10, 1) over N(-10,1) but it currently believes that the two Gaussians are equiprobable. This has to do with its use of a relatively untested webchurch feature: supplying a
conditioned-value
argument to a continuous ERP, e.g., the third argument to(gaussian 10 1 10)
.Noah and I tracked the bug down to these lines in
RandomExecutionTrace.prototype.proposeChange
:Because MH only proposes changes to
x
and the kernel forflip
always proposes switching to the other value (false to true, true to false), the forward and reverse proposal probabilities for this model should always be 1 but aren't. This is becausenewlogprob
andoldlogprob
are including the scores of the conditioned variables.newlogprob
is updated inRandomExecutionTrace.prototype.lookup
:Notice that there is also a
genlogprob
property that only keeps track of variables that were truly generated.And
oldlogprob
is updated inRandomExecutionTrace.prototype.traceUpdate
:My proposed fixes are:
genlogprob
rather thannewlogprob
. I'm not positive that this is the right fix becausenewlogprob
is modified in LARJ (so maybe this change would break inference in LARJ?)oldlogprob
:I'm more confident about this second fix but it'd be nice to have independent confirmation that this is sane.
Thoughts?