# Calculating Conditional Probability Table (Migrated from community.research.microsoft.com)

• ### Question

• xyc posted on 06-22-2009 10:00 PM

Hi,

I'm new to Infer.NET and I'm trying to understand how to use it by coding a sub-set of my bayesian network which is similar to the following model.

S                                   M
p(s) = 0.3                 p(m) = 0.6
\                           /
\                       /
\                   /
L     p(l|s,m) = 0.05
|      p(l|s,~m) = 0.1
|     p(l|~s,m) = 0.1
|     p(l|~s,~m) = 0.2
|
T   p(t|l) = 0.3
p(t|~l) = 0.8

I can create the model using the example given in a previous thread.  But, in my actual network, variables S and M each have 10 discrete states. This means variable L would have 100 rows in its conditional probability table (CPT).  I would like to calculate the CPT values as required using Kevin Murphy's formula which is suitable for my needs.

p(L|S,M) = [p(L|S)p(L|M)] / p(L)

This would mean I wouldn't have to code 100 rows of Variable.If() conditions, especially when this is just a sub-set of my actual model.  In my model variable L will be dependent on a few more other variables, each having more states, so there will be much more than 100 rows in the resulting CPT.

I've tried several different ways to code this in Infer.NET, none of which really gives me a full model.  In one attempt I broke the model into different sections: I code the top-half of the model first (S, M, L); calculate the CPT as required given the observations; then substitute this value into the bottom-half of the model (L, T).  It works if I only ever make inferences on the bottom variables (e.g. T).  But if T is my observed variable and I want to infer something at the top (e.g. M) this attempt will not handle it.

What would be the best approach for this?  Any assistant would be greatly appreciated.

Thanks,
xyc

Friday, June 3, 2011 4:55 PM