Infer.NET user guide : Fun

Computing Model Evidence

(See file Samples\Fun\Evidence\Evidence.fs.)

We can use if-statements to compute a measure for the likelihood of our models. The idea is to surround the model with an if-statement guarded by the result of a fair coin toss. If our model is very likely (all observations hold with high probability) then the posterior distribution of the coin will remain close to fair. If our model is not likely, then the coin will be skewed towards false. The following example illustrates the idea:

let model () =
    let evidence = random(Bernoulli(0.5))

    if evidence then
        let coin = random(Bernoulli(0.6))
        observe(coin = true)

©2009-2013 Microsoft Corporation. All rights reserved.  Terms of Use | Trademarks | Privacy Statement