Recent changes to support-requestshttps://sourceforge.net/p/unbbayes/support-requests/2014-07-24T22:10:12Z#7 calculation of joint probability2014-07-24T22:10:12Z2014-07-24T22:10:12Zcardialflyhttps://sourceforge.net/u/cardialfly/https://sourceforge.netcaf4114fcffc97ebba9b2c18333c84573c211a2e<div class="markdown_content"><p>Hello, Giannis;</p>
<p>If I'm not wrong, calling the method JunctionTreeAlgorithm#run() in the object you instantiated should re-build the junction tree -- of the network you've set with JunctionTreeAlgorithm#setNet(ProbabilisticNetwork) -- for you. </p>
<p>Of course, I'm assuming the JunctionTreeAlgorithm and all objects aggregated to/with it were correctly instantiated. <br />
Normally some exception should be thrown if there is some requirement not properly settled at this point (I can't imagine in advance what kind of problems may happen to you, because honestly I'm not sure how you've instantiated the 1st junction tree -- to obtain the joint probability before changes in CPT -- at all). You can try and see what happens.</p>
<p>Best regards.</p></div>#7 calculation of joint probability2014-07-24T08:42:30Z2014-07-24T08:42:30ZGiannisChhttps://sourceforge.net/u/gchant/https://sourceforge.net45d2debbc5ce05ef6b13ff18f53451c18edce311<div class="markdown_content"><p>Hi cardialfly,</p>
<p>Thank you for your prompt reply!<br />
Can you please explain how can I recompile the junction tree?<br />
What I am doing at the beggining of each CPT update iteration is (before the update) to create a new JunctionTreeAlgorithm object (.. = new JunctionTreeAlgorithm() ) and then use the SetNet method to the CPT updated network.</p>
<p>Is there a specific method that I have to also call?</p>
<p>Thank you.</p></div>#7 calculation of joint probability2014-07-23T17:04:11Z2014-07-23T17:04:11Zcardialflyhttps://sourceforge.net/u/cardialfly/https://sourceforge.nete0661c0996cdecb029cea97317ae2483f6f340a4<div class="markdown_content"><p>Hi, Giannis.</p>
<p>Could you make sure you recompiled the network (i.e. call the method in JunctionTreeAlgorithm which you supposedly used to compile the junction tree the first time)? The joint probability is calculated from a junction tree, which may have been built/compiled from the old network (i.e. the one before your change).</p>
<p>In UnBBayes (not only in it, though), Bayes nets and junction trees are different entities (they are like different structures trying to represent equivalent prob. distribution), so updating the CPT (a component in Bayes net) won't update the content of the junction tree unless you manually synchronize them.</p>
<p>Recompiling the junction tree forces such synchronization, or should I say it simply creates a new junction tree from the updated Bayes net.</p>
<p>Regards,</p></div>#7 calculation of joint probability2014-07-23T11:30:42Z2014-07-23T11:30:42ZGiannisChhttps://sourceforge.net/u/gchant/https://sourceforge.neta6f2a0b435fa99debf3c9c8ca3a35aa58456d701<div class="markdown_content"><p>Hi all,</p>
<p>I have a problem regarding the computation of the joint probability of nodes. Specifically, although the JunctionTreeAlgorithm provides the joint probabilities at a first step, at a second step after I change the CPTs (through the getProbabilityFunction method of the ProbabilisticNode class and using the setup provided in the above code), and recalcuate the joint probabilities, they remain the same.</p>
<p>I am not sure what I am doing wrong. Do I miss something crucial regarding the junction tree algorithm class.</p>
<p>Thank you for your help,</p>
<p>Giannis</p></div>#7 calculation of joint probability2013-09-11T17:18:53Z2013-09-11T17:18:53Zcardialflyhttps://sourceforge.net/u/cardialfly/https://sourceforge.netd136fe280c57d99276133d5c95000c5357b70472<div class="markdown_content"><p>My apologies for the late reply.</p>
<p>I guess the getJointProbability is returning the joint probability of the nodes you specify in the arguments plus the evidences you inserted, so the last joint probability, for example, seems to be the joint probability of nodes 5 (evidence), 13, and 15 together...</p>
<p>I'll see if I can fix this issue quickly.</p>
<p>While the problem is not fixed, you may try using a workaround instead, which is to absorb the node with evidence, by deleting it:<br />
ProbabilisticNetwork#removeNode(Node, boolean);</p>
<p>In your code, it would be something like:<br />
net.removeNode(node5, true);</p>
<p>One issue I foresee in absorbing a node is that the node won't exist anymore; so, you may find strange issues while resetting evidences, for example.</p>
<p>Apologies for all the inconvenience.<br />
Sincerely.</p></div>#7 calculation of joint probability2013-09-05T01:37:43Z2013-09-05T01:37:43Zcardialflyhttps://sourceforge.net/u/cardialfly/https://sourceforge.net607252e1de300b282e483a0b066e84b507bc4e28<div class="markdown_content"><p>Hello, Vincenzo. Thanks for your attention on UnBBayes.</p>
<p>I'm starting to suspect that your issue is actually a rounding/precision problem of Java's floating point numbers. If so, I'm not sure if the effort of fixing it would worth the result.</p>
<p>UnBBayes does not assume that findings (evidences) comes from only 1 source/node. Therefore, when you propagate an evidence, it will attempt to settle global consistency of all cliques anyway (so, when you insert an evidence on a node and propagate, UnBBayes will check global consistency of other nodes regardless of being connected or not).</p>
<p>At that point (settling global consistency), UnBBayes multiplies clique potentials and then divide by separator potentials. Virtually, it does X = X*Y/Z in lots of places. </p>
<p>We know that X*Y/Z is mathematically equal to X if Y=Z (in this case, the value of X will remain unchanged), but in floating point operations, X*Y/Z may give slightly different results because of precision, especially if values are not multiple of 2, or when the order of operations may change, or due to lots of other possible sources of imprecision - because the inputs are not precisely the same for the system as a whole, if you insert an evidence somewhere.</p>
<p>When I ran your example (which I got from Rommel), I realized that when you propagated the evidence of node 5, the state 0 of node 13 changed from 0.68746004 to 0.68746006, and the state 0 of node 11 changed from 1.0 to 1.0000001 (OK, this may give some problems for applications calling UnBBayes). This really sounds to me like a precision problem, especially in UnBBayes, which was originally created as a GUI-based application whose the GUI only used (and still uses) 4 significant digits.</p>
<p>So, I'm afraid I have to ask you to deal with it (perhaps by using Math.round(), or simply accepting the "floating" precision)... Most of UnBBayes applications ran OK with this level of precision actually (this level of difference did not make differences in decisions, because I suppose Bayes nets don't encode model credibility anyway).</p>
<p>My apologies for any inconvenience, and pardon-me in case this wasn't helpful at all.</p>
<p>My best regards.</p></div>#7 calculation of joint probability2013-09-02T11:16:08Z2013-09-02T11:16:08ZRommel Novaes Carvalhohttps://sourceforge.net/u/rommelnc/https://sourceforge.netf73da82ff3d8423fc999b6b1ab28f92800dac6fb<div class="markdown_content"><p>Hi Vincenzo,</p>
<p>Could you please attach the network you are making these tests here? We will take a look at it.</p>
<p>Cheers,<br />
Rommel</p></div>#7 calculation of joint probability2013-09-02T11:14:49Z2013-09-02T11:14:49ZRommel Novaes Carvalhohttps://sourceforge.net/u/rommelnc/https://sourceforge.netf3642d32442787cf87071eaa7da35a93581c5ca0<div class="markdown_content"><ul>
<li><strong>status</strong>: closed --> open</li>
</ul></div>#7 calculation of joint probability2013-08-09T11:56:47Z2013-08-09T11:56:47Zcardialflyhttps://sourceforge.net/u/cardialfly/https://sourceforge.net507241af54f22db2ed97fc3ab6a3a39f610a9547<div class="markdown_content"><blockquote>
<blockquote>
<p>(...) given 2 or more nodes, is able to retrieve their joint probability distribution (after the propagation of some belief)</p>
</blockquote>
</blockquote>
<p>In the source code in SVN repository, we can find the method "getJointProbability" in the class JunctionTreeAlgorithm (line 1466 of <a href="https://sourceforge.net/p/unbbayes/code/2714/tree/trunk/UnBBayes/src/main/java/unbbayes/prs/bn/JunctionTreeAlgorithm.java">https://sourceforge.net/p/unbbayes/code/2714/tree/trunk/UnBBayes/src/main/java/unbbayes/prs/bn/JunctionTreeAlgorithm.java</a>), which can be used to query P(C = c1, D = d2).</p>
<p>So, I believe that in order to calculate P(C = c1, D = d2 | A = a1, B = b1), you may need to first insert and propagate the evidences A = a1, B = b1, and then call "getJointProbability" for P(C = c1, D = d2), so that the result becomes numerically equivalent to P(C = c1, D = d2 | A = a1, B = b1).</p>
<p>I'm not entirely sure, but there is a chance (actually, risk) that "getJointProbability" resets previous findings (so, calling "getJointProbability" after propagating "A = a1, B = b1" may cancel "A = a1, B = b1"). In such case, you may also want to absorb the findings "A = a1, B = b1" (i.e. delete nodes A and B by calling the method "unbbayes.prs.bn.ProbabilisticNetwork#removeNode") before calling "getJointProbability".</p>
<p>Best regards.</p></div>#7 calculation of joint probability2013-08-09T01:55:58Z2013-08-09T01:55:58ZVincenzo Laganihttps://sourceforge.net/u/vincenzolagani/https://sourceforge.net4159449c0e6d436cf2559ff30bf7e2bebda973de<div class="markdown_content"><p>Thanks a lot for your prompt reply!</p>
<p>The example is pretty much illuminating. Unfortunately, it is not exactly what I need: the method "getMarginalAt()" returns the marginal probability for a single status of a single node. I need the joint probability of two or more nodes, instead.</p>
<p>A little bit more formally:</p>
<p>Given the BN nodes A, B, C, D, and some evidence a1 and b1 for A and B, the "getMarginal()" method can retrieve probabilities like:</p>
<p>p(C = c1 | A = a1, B = b1)<br />
p(D = d2 | A = a1, B = b1)<br />
etc.</p>
<p>what I need is instead:</p>
<p>p(C = c1, D = d2 | A = a1, B = b1)</p>
<p>Unfortunately, this joint probability is not a simple product of marginals when C and D are not d-separated by A and B.</p>
<p>To cut a long story short, I need to know if UnBBayes has any method that, given 2 or more nodes, is able to retrieve their joint probability distribution (after the propagation of some belief)</p>
<p>Thanks again,</p>
<p>Vincenzo</p></div>