The two coins example in Matlab

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

Matlab script

dllFolder = 'c:\Program Files\Infer.NET\Bin';
NET.addAssembly(fullfile(dllFolder,'Infer.Compiler.dll'));
NET.addAssembly(fullfile(dllFolder,'Infer.Runtime.dll'));
import MicrosoftResearch.Infer.Distributions.*
import MicrosoftResearch.Infer.Models.*
import MicrosoftResearch.Infer.*
import System.*

% The model
b = Bernoulli(0.5);
firstCoin = Variable.Bernoulli(0.5);
secondCoin = Variable.Bernoulli(0.5);
% methods(firstCoin) gives all operations that can be performed
bothHeads = firstCoin.op_BitwiseAnd(firstCoin, secondCoin);

% The inference
ie = InferenceEngine();
disp(['Probability both coins are heads: ' char(ie.Infer(bothHeads).ToString)]);
bothHeads.ObservedValue = false;
disp(['Probability distribution over firstCoin: ' char(ie.Infer(firstCoin).ToString)]);
©2009-2015 Microsoft Corporation. All rights reserved.  Terms of Use | Trademarks | Privacy Statement