Answered by:
Dependency of Random Variables in infer.net (Migrated from community.research.microsoft.com)
Question

kindloaf posted on 06122009 7:05 PM
Hi,
I used the following code to get the distribution of a random variable, seems the result is not correct.
Variable<bool> A = Variable.Bernoulli(0.5).Named("A");
Variable<bool> D = (A & A).Named("D");
InferenceEngine ie = new InferenceEngine();
Console.WriteLine("D = " + ie.Infer(D));Essentially variable D is the same as A, but the distribution calculated is D = Bernoulli(0.25) instead of Bernoulli 0.5.
I am wondering if i did something wrong or infer.net does not support this kind of dependency.Can anyone help me with this? Thanks!
Friday, June 3, 2011 4:57 PM
Answers

minka replied on 07142009 8:00 AM
What is the question being asked in this case? The student now has several options of how to take the courses, so it isn't clear what is meant by "the probability of passing a particular course". Does the student choose one set of prerequisites which give highest probability? What does the student do when this choice of prerequisites fails?
 Marked as answer by Microsoft Research Friday, June 3, 2011 4:58 PM
Friday, June 3, 2011 4:58 PM
All replies

minka replied on 06152009 9:14 AM
kindloaf is right in saying that Infer.NET does not give the exact answer on this example. The reason is that Infer.NET performs approximate inference so it is not always going to be exact. Infer.NET fits a fully factorized posterior distribution, which essentially assumes that the variables used in a factor are statistically independent. This particular model is a pathological case where two arguments to a factor (the plus factor) are the same variable, and thus highly dependent. Luckily these sorts of models don't arise very often in practice. If you have a real model where you need to use the same variable twice in a factor, please let us know and we can try to address that on a casebycase basis.
Friday, June 3, 2011 4:57 PM 
kindloaf replied on 06162009 10:49 AM
Thank you for your reply minka.
I have a case which is similar to the following one:
Suppose there is a university with a very special curriculum. There are a number of courses in the curriculum. Each course can either be taken directly or has a number of prerequisites. One can take a course which has prerequisite(s) only when one passes all the prerequisites. When a student takes a course, he/she may fail or pass the course with a fixed probability. A student can only take a course once.
Now given the probability that a student can pass each course, what is the probability the student can pass a particular course?
Can this problem be solved using infer.net? Or is there any suggestion how to solve this problem?
A trivial example is as follows:
Courses: A, B, C, D
Prerequisites:
A:none
B:A
C:A
D:BC
Probability of passing:
A:0.8
B:0.7
C:0.9
D:1.0
The probability of passing D is: 0.8*0.7*0.9 = 0.504Friday, June 3, 2011 4:57 PM 
minka replied on 07032009 11:08 AM
You don't really need Infer.NET for this problem. In this problem, the graph structure of the prerequisites is not really important. Define the "transitive prerequisites" of a course to be the set of all immediate prerequisites plus of all their prerequisites and so on. To take a course, you must pass all of the transitive prerequisites. The fact that you must pass them in a particular order is irrelevant. The answer is just the product of the probabilities of passing the course and all of its transitive prerequisites.
You could solve this problem with Infer.NET, although the answers would not necessarily be exact, depending on how you encoded the problem. If you encode the problem as a graph of binary variables whose dependencies correspond to the prerequisite graph, then the answer would be exact as long as the prerequisites graph has no loops. Alternatively, if you link the variables according to transitive prerequisites, then the answer would be exact, since it is just a case of multiplying the probabilities of independent events.
Friday, June 3, 2011 4:57 PM 
minka replied on 07032009 11:11 AM
To clarify, in the second case I mean linking only the course of interest with its transitive prerequisites, with no other links.
Friday, June 3, 2011 4:57 PM 
kindloaf replied on 07062009 9:48 AM
Thank you for the timely reply. The solution is elegant.
May I ask an extension of it? Now suppose for each courses, there is a number of sets of prerequisites. Passing all the prerequisites of any set will be good for taking the course. For example, a course X may have 3 sets of prerequisites, ABC, DE or ABE. This means the student can take X if passing ABC, or DE, or ABE. Any suggestions on how to solve that?
Friday, June 3, 2011 4:58 PM 
minka replied on 07142009 8:00 AM
What is the question being asked in this case? The student now has several options of how to take the courses, so it isn't clear what is meant by "the probability of passing a particular course". Does the student choose one set of prerequisites which give highest probability? What does the student do when this choice of prerequisites fails?
 Marked as answer by Microsoft Research Friday, June 3, 2011 4:58 PM
Friday, June 3, 2011 4:58 PM