Dependency of Random Variables in infer.net (Migrated from community.research.microsoft.com)<p><b>kindloaf posted on 06-12-2009 7:05 PM</b></p>
<p>Hi,</p>
<p>I used the following code to get the distribution of a random variable, seems the result is not correct.</p>
<p> Variable<bool> A = Variable.Bernoulli(0.5).Named("A");<br/>
Variable<bool> D = (A & A).Named("D");<br/>
InferenceEngine ie = new InferenceEngine();<br/>
Console.WriteLine("D = " + ie.Infer(D));</p>
<p>Essentially variable D is the same as A, but the distribution calculated is D = Bernoulli(0.25) instead of Bernoulli 0.5.<br/>
I am wondering if i did something wrong or infer.net does not support this kind of dependency.</p>
<p>Can anyone help me with this? Thanks!</p>© 2009 Microsoft Corporation. All rights reserved.Fri, 03 Jun 2011 16:58:17 Z54d8ee6b-25ab-440c-8497-0e1b2aa35e7c- https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#54d8ee6b-25ab-440c-8497-0e1b2aa35e7chttps://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#54d8ee6b-25ab-440c-8497-0e1b2aa35e7cMicrosoft Researchhttps://social.microsoft.com:443/profile/microsoft%20research/?type=forumDependency of Random Variables in infer.net (Migrated from community.research.microsoft.com)<p><b>kindloaf posted on 06-12-2009 7:05 PM</b></p>
<p>Hi,</p>
<p>I used the following code to get the distribution of a random variable, seems the result is not correct.</p>
<p> Variable<bool> A = Variable.Bernoulli(0.5).Named("A");<br/>
Variable<bool> D = (A & A).Named("D");<br/>
InferenceEngine ie = new InferenceEngine();<br/>
Console.WriteLine("D = " + ie.Infer(D));</p>
<p>Essentially variable D is the same as A, but the distribution calculated is D = Bernoulli(0.25) instead of Bernoulli 0.5.<br/>
I am wondering if i did something wrong or infer.net does not support this kind of dependency.</p>
<p>Can anyone help me with this? Thanks!</p>Fri, 03 Jun 2011 16:57:21 Z2011-06-03T16:57:21Z
- https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#cabe7198-f23a-48b3-9023-952098cfa66chttps://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#cabe7198-f23a-48b3-9023-952098cfa66cMicrosoft Researchhttps://social.microsoft.com:443/profile/microsoft%20research/?type=forumDependency of Random Variables in infer.net (Migrated from community.research.microsoft.com)<p><b>minka replied on 06-15-2009 9:14 AM</b></p>
<p>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 case-by-case basis.</p>Fri, 03 Jun 2011 16:57:35 Z2011-06-03T16:57:35Z
- https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#5f6db16f-7a35-4d10-a7c4-922fcc90cfb1https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#5f6db16f-7a35-4d10-a7c4-922fcc90cfb1Microsoft Researchhttps://social.microsoft.com:443/profile/microsoft%20research/?type=forumDependency of Random Variables in infer.net (Migrated from community.research.microsoft.com)<p><b>kindloaf replied on 06-16-2009 10:49 AM</b></p>
<p>Thank you for your reply minka.<br/>
<br/>
I have a case which is similar to the following one:<br/>
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.<br/>
<br/>
Now given the probability that a student can pass each course, what is the probability the student can pass a particular course?<br/>
<br/>
Can this problem be solved using infer.net? Or is there any suggestion how to solve this problem?<br/>
<br/>
A trivial example is as follows:<br/>
<br/>
Courses: A, B, C, D<br/>
<br/>
Prerequisites:<br/>
A:none<br/>
B:A<br/>
C:A<br/>
D:BC<br/>
<br/>
Probability of passing:<br/>
A:0.8<br/>
B:0.7<br/>
C:0.9<br/>
D:1.0<br/>
<br/>
The probability of passing D is: 0.8*0.7*0.9 = 0.504</p>Fri, 03 Jun 2011 16:57:47 Z2011-06-03T16:57:47Z
- https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#389311c1-94d1-4151-9721-99e46794119chttps://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#389311c1-94d1-4151-9721-99e46794119cMicrosoft Researchhttps://social.microsoft.com:443/profile/microsoft%20research/?type=forumDependency of Random Variables in infer.net (Migrated from community.research.microsoft.com)<p><b>minka replied on 07-03-2009 11:08 AM</b></p>
<p>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. </p>
<p>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.</p>Fri, 03 Jun 2011 16:57:50 Z2011-06-03T16:57:50Z
- https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#52b31cf9-4b5d-4c2e-aee7-1e6a01cc2f08https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#52b31cf9-4b5d-4c2e-aee7-1e6a01cc2f08Microsoft Researchhttps://social.microsoft.com:443/profile/microsoft%20research/?type=forumDependency of Random Variables in infer.net (Migrated from community.research.microsoft.com)<p><b>minka replied on 07-03-2009 11:11 AM</b></p>
<p>To clarify, in the second case I mean linking only the course of interest with its transitive prerequisites, with no other links.</p>Fri, 03 Jun 2011 16:57:56 Z2011-06-03T16:57:56Z
- https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#00752760-a5d9-4ec3-851b-51313dd61efchttps://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#00752760-a5d9-4ec3-851b-51313dd61efcMicrosoft Researchhttps://social.microsoft.com:443/profile/microsoft%20research/?type=forumDependency of Random Variables in infer.net (Migrated from community.research.microsoft.com)<p><b>kindloaf replied on 07-06-2009 9:48 AM</b></p>
<p>Thank you for the timely reply. The solution is elegant.</p>
<p>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?</p>Fri, 03 Jun 2011 16:58:04 Z2011-06-03T16:58:04Z
- https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#5cb2942d-4375-4aed-ade9-b13077265c69https://social.microsoft.com/Forums/en-US/54d8ee6b-25ab-440c-8497-0e1b2aa35e7c/dependency-of-random-variables-in-infernet-migrated-from-communityresearchmicrosoftcom?forum=infer.net#5cb2942d-4375-4aed-ade9-b13077265c69Microsoft Researchhttps://social.microsoft.com:443/profile/microsoft%20research/?type=forumDependency of Random Variables in infer.net (Migrated from community.research.microsoft.com)<p><b>minka replied on 07-14-2009 8:00 AM</b></p>
<p>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?</p>Fri, 03 Jun 2011 16:58:07 Z2011-06-03T16:58:07Z