Computing evidence for models with shared variables
Computing evidence in a shared variable model requires special treatment. In the non-shared variable case we just created a Variable<bool> evidence variable and wrapped the whole model in an IfBlock. The log evidence of the model was then given by the log odds of the evidence variable's marginal.
The following snippets show how to deal with evidence in the shared variable case, using the LDA shared variable example. You must first explicitly mark the evidence variable as such by setting the shared variable's IsEvidenceVariable property to true:
Then wrap each model with an IfBlock conditioned on the model's copy of the evidence variable:
Finally, retrieve the log evidence by call the GetEvidenceForAll method, and passing in all models: