The two coins example in F#

For a description of this tutorial and the C# code please see the two coins tutorial.

F# script

#light

// Reference the Infer.NET DLLs
#r @"C:\Program Files\Microsoft Research\Infer.NET 2.4\bin\Release\Infer.Compiler.dll"
#r @"C:\Program Files\Microsoft Research\Infer.NET 2.4\bin\Release\Infer.Runtime.dll"
#r @"C:\Program Files\Microsoft Research\Infer.NET 2.4\bin\Release\Infer.FSharp.dll"

open MicrosoftResearch.Infer
open MicrosoftResearch.Infer.Models
open MicrosoftResearch.Infer.Distributions
open MicrosoftResearch.Infer.Factors
open MicrosoftResearch.Infer.FSharp

//-----------------------------------------------------------------------------------
// Infer.NET: F# script for the two coins example
//-----------------------------------------------------------------------------------

// The model
let firstCoin = Variable.Bernoulli(0.5)
let secondCoin = Variable.Bernoulli(0.5)
let bothHeads = firstCoin &&& secondCoin

// The inference
let ie = InferenceEngine()

let bothHeadsPost = ie.Infer<Bernoulli>(bothHeads)
printfn "Both heads posterior = %A" bothHeadsPost
bothHeads.ObservedValue <- false

let
firstCoinPost = ie.Infer<Bernoulli>(firstCoin)
printfn "First coin posterior = %A" firstCoinPost

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