Closed haohaiziround closed 6 years ago
We cannot compile the model with let statement/ variable declaration inside ifs. For example, the following code does not compile correctly.
(let [x1 (sample (normal 0 1)) y 1] (if (> x1 0) (let [x2 (sample (normal 0 1))] (observe (normal x2 1) y)) (let [x3 (sample (normal 0 1))] (observe (normal x3 1) y))) (vector x1 x2 x3))
Also, the code above should behave the same as the code beneath (in terms of the joint, ie. the final logp) since the sample statements only contribute priors to the joint no matter inside branch or outside branch.
(let [x1 (sample (normal 0 1)) x2 (sample (normal 0 1)) x3 (sample (normal 0 1)) y 1] (if (> x1 0) (observe (normal x2 1) y) (observe (normal x3 1) y)) (vector x1 x2 x3))
My bad. Some simple error in the return statement.
We cannot compile the model with let statement/ variable declaration inside ifs. For example, the following code does not compile correctly.
Also, the code above should behave the same as the code beneath (in terms of the joint, ie. the final logp) since the sample statements only contribute priors to the joint no matter inside branch or outside branch.