Answered by:
Inferring Joint distributions (Migrated from community.research.microsoft.com)
Question

Kirali posted on 03012011 12:00 AM
Hi, I am using a bayesnet for an application very similar to the one described here. Thanks a lot for your time, I found it very useful.
I have a question regarding inference.
I am able to infer on one random variable using
var distr = InfEngine.Infer<Discrete[]>(CarModel);
This evaluates P(CarModel  evidence).
If I want to find the joint distribution of 2 or more random variables.
Say I want to find the joint distribution of CarModel and CarColor
So I want to evaluate P(CarModel,CarColor  evidence)
How do I do this?
Friday, June 3, 2011 6:29 PM
Answers

minka replied on 03062011 7:17 AM
You first need to fit a model to the data, then you ask P(CarMake, CarModel  CarBody = Sedan) from the model (not the data). Observe CarBody=Sedan, then loop over all possible values for CarMake and CarModel and set their ObservedValues. The model gives you the probability for each combination. Normalize to get the conditional distribution.
 Marked as answer by Microsoft Research Friday, June 3, 2011 6:30 PM
Friday, June 3, 2011 6:29 PM
All replies

minka replied on 03012011 2:59 AM
Infer.NET uses factorized approximations so it doesn't directly compute joint distributions. If you asked for one, you would get the product of univariate marginals which is probably not what you want. However, you can use the general machinery for computing the probability of a joint event, as described here. You would loop over all possible joint states and query the probability of each one. This would give you p(CarModel, CarColor, evidence) for each value of (CarModel, CarColor). Sum over (CarModel, CarColor) to get p(evidence) and divide by this to get your conditional joint distribution.
Friday, June 3, 2011 6:29 PM 
Kirali replied on 03042011 10:00 PM
CarMake
CarModel
CarBody
honda
accord
Sedan
Acura
mdx
Coupe
honda
civic
Sedan
Acura
mdx
Sedan
Ford
ikon
Coupe
Acura
mdx
Sedan
honda
accord
Sedan
honda
crv
SUV
Just to make it for clear, can u explain on this data.
I want to evaluate P(CarMake, CarModel  CarBody = Sedan)
Friday, June 3, 2011 6:29 PM 
minka replied on 03062011 7:17 AM
You first need to fit a model to the data, then you ask P(CarMake, CarModel  CarBody = Sedan) from the model (not the data). Observe CarBody=Sedan, then loop over all possible values for CarMake and CarModel and set their ObservedValues. The model gives you the probability for each combination. Normalize to get the conditional distribution.
 Marked as answer by Microsoft Research Friday, June 3, 2011 6:30 PM
Friday, June 3, 2011 6:29 PM