# Inspecting EP Evidence Contributions • ### Question

• Hi, I'm new to Infer.NET, and am experimenting with estimating model evidences with Expectation Propagation.

How is it possible to look at the evidence contributions that EP calculates from each factor and variable? I have the following code which can calculate the evidence for a model where a coin is tossed and there is a beta prior on the probability of heads:

```namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] data = new int[] { 0, 1};

Variable<Vector> p;
double[] prior = new double;

var evidence = Variable.Bernoulli(0.5);
using (Variable.If(evidence))
{
prior = 1; prior = 1;
p = Variable.Dirichlet(prior);

Range r = new Range(data.Length);
VariableArray<int> x = Variable.Array<int>(r);
x[r] = Variable.Discrete(p).ForEach(r);
x.ObservedValue = data;

}
var ieEP = new InferenceEngine(new ExpectationPropagation());
ieEP.NumberOfIterations = 1;
ieEP.ShowProgress = true;
var logodds =  ieEP.Infer<Bernoulli>(evidence).LogOdds;

Console.WriteLine("Evidence: "+ logodds);
Console.WriteLine("exp() = " + Math.Exp(logodds));
Console.ReadKey();
}
}
}```

This gives the correct answer of log(1/6) because the probability of the first heads was 1/2, this updated the prior to being beta(2,1) meaning the prob of the next being tails was 1/3.

But I'd like to look at the individual messages which went into this calculation, including the messages to the gate and the evidence contributions at each node in the factor graph (see http://johnwinn.org/Publications/papers/Minka_Winn_Gates_NIPS2008.pdf)

Any help would be greatly appreciated,

Matt

Monday, June 11, 2012 4:18 PM