# inferring a variable which is not explicitly assigned a distriubtion

• ### Question

• If I define the distribution on a variable based on some conditions, like w in below code:

```gamma[featureRange] = Variable.Bernoulli(rhoPriors[featureRange]);
using (Variable.ForEach(featureRange)) spike[featureRange] = Gaussian.FromMeanAndVariance(0, 0.0000001);
using (Variable.ForEach(featureRange)) slab[featureRange] = Gaussian.FromMeanAndVariance(0, 1);

using (Variable.ForEach(featureRange))
{
using (Variable.If(gamma[featureRange]))
{
w[featureRange] = Variable<double>.Random(slab[featureRange]);
}
using (Variable.IfNot(gamma[featureRange]))
{
w[featureRange] = Variable<double>.Random(spike[featureRange]);
}
}```

Is it possible to infer w directly and use the values directly from this inferred w? And are these inferred values for w usable for test purposes? Or I should infer gamma and state w in terms of gamma?

I get some very large values for w, which is not logical in my case. I wanted to ask if it is at all possible to use engine.infer<Gaussian[]>(w). Thanks a lot.

My model is a simple regression. Actually when I put a constraint on w, the result become really great. That's while putting such a constraint on w, makes no sense in theory. I was wondering how the value of w can be used.

```// my ConstrainPositive on w
Variable.ConstrainPositive(w[featureRange]);```

• Edited by Tuesday, November 25, 2014 10:24 AM
Tuesday, November 25, 2014 9:57 AM

• What error do you get when you use engine.Infer<Gaussian[]>(w)?
• Marked as answer by Thursday, November 27, 2014 3:50 PM
Tuesday, November 25, 2014 11:35 AM

### All replies

• What error do you get when you use engine.Infer<Gaussian[]>(w)?
• Marked as answer by Thursday, November 27, 2014 3:50 PM
Tuesday, November 25, 2014 11:35 AM
• Excuse me my problem is solved. I had a mistake in implementing the noise term.

Thank you. If I could, I would just delete this post because I found out this is not useful, the question is wrong.