# calculation precision (Migrated from community.research.microsoft.com) • ### Question

• amchiclet posted on 03-04-2010 1:56 PM

I have the following code.

Variable<bool> x = Variable.Bernoulli(0.5);
Variable<bool> y = Variable.Bernoulli(0.5);

Variable<bool> xt = (x == true);
Variable<bool> xf = (x == false);
Variable<bool> yt = (y == true);
Variable<bool> yf = (y == false);

Variable<bool> tt = (xt & yt);
Variable<bool> ff = (xf & yf);

When I use this constraint:

Variable.ConstrainEqualRandom(tt, Bernoulli.FromLogOdds(Math.Log(2.0)));

I get: x = Bernoulli(0.6), y = Bernoulli(0.6)

However, when I use this constraint:

Variable.ConstrainEqualRandom(tt & !ff, Bernoulli.FromLogOdds(Math.Log(2.0)));

I get: x = Bernoulli(0.6115), y = Bernoulli(0.6115)

I thought both constraints should yield equivalent results. Is anything happening differently in the background?

Friday, June 3, 2011 5:36 PM

• amchiclet replied on 03-05-2010 3:32 PM

Gotcha, thanks!

Friday, June 3, 2011 5:36 PM

### All replies

• minka replied on 03-05-2010 4:04 AM

Welcome to approximate inference!  The second example gives a different result because the graphical model has a loop.  See this thread for a similar discussion: http://community.research.microsoft.com/forums/t/4202.aspx

Friday, June 3, 2011 5:36 PM
• amchiclet replied on 03-05-2010 3:32 PM

Gotcha, thanks!

Friday, June 3, 2011 5:36 PM