The two coins example in IronPython

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

IronPython script

#-----------------------------------------------------------------------------------
# Infer.NET IronPython example: Two Coins
#-----------------------------------------------------------------------------------

import InferNetWrapper
from InferNetWrapper import *

# two coins example
def two_coins() :
    print("\n\n------------------ Infer.NET Two Coins example ------------------\n");

    # The model
    b = MicrosoftResearch.Infer.Distributions.Bernoulli(0.5)
    firstCoin = Variable.Bernoulli(0.5)
    secondCoin = Variable.Bernoulli(0.5)
    bothHeads = firstCoin & secondCoin

    # The inference
    ie = InferenceEngine()
    print "Probability both coins are heads:", ie.Infer(bothHeads)
    bothHeads.ObservedValue = False
    print "Probability distribution over firstCoin:", ie.Infer(firstCoin)
©2009-2015 Microsoft Corporation. All rights reserved.  Terms of Use | Trademarks | Privacy Statement