Closed andredd closed 7 years ago
After studying the gibbs sampling code and doing an extensive debugging run of the above submitted code I noted that the probability over markov blanket being calculated is over the same event regardless of the new values being assigned to Xi over the loop. I believe that is the cause of the problem although I may be wrong.
The normalized probability values being returned are [0.56, 0.24] in the case of {parent = true, child = true} for the above test case. I believe it should be [0.56, 0.06]. Could this be verified?
public static double[] mbDistribution(Node Xi,
Map<RandomVariable, Object> event) {
FiniteDomain fd = (FiniteDomain) Xi.getRandomVariable().getDomain();
double[] X = new double[fd.size()];
for (int i = 0; i < fd.size(); i++) {
double cprob = 1.0;
for (Node Yj : Xi.getChildren()) {
cprob *= Yj.getCPD().getValue(
getEventValuesForXiGivenParents(Yj, event));
}
X[i] = Xi.getCPD()
.getValue(
getEventValuesForXiGivenParents(Xi,
fd.getValueAt(i), event))
* cprob;
}
return Util.normalize(X);
}
I have this on my TODO list to investigate more closely. Thanks.
On Wed, Mar 22, 2017 at 6:49 AM, Nagaraj Poti notifications@github.com wrote:
After studying the gibbs sampling code and doing an extensive debugging run of the above submitted code I noted that the probability over markov blanket being calculated is over the same event regardless of the new values being assigned to Xi over the loop. I believe that is the cause of the problem although I may be wrong.
The normalized probability values being returned are [0.56, 0.24] in the case of {parent = true, child = true} for the above test case. I believe it should be [0.56, 0.06].
`public static double[] mbDistribution(Node Xi, Map<RandomVariable, Object> event) { FiniteDomain fd = (FiniteDomain) Xi.getRandomVariable().getDomain(); double[] X = new double[fd.size()];
for (int i = 0; i < fd.size(); i++) { // P(x'i|mb(Xi)) = // αP(x'i|parents(Xi)) // ∏Yj ∈ Children(Xi) // P(yj|parents(Yj)) double cprob = 1.0; for (Node Yj : Xi.getChildren()) { cprob = Yj.getCPD().getValue( getEventValuesForXiGivenParents(Yj, event)); } X[i] = Xi.getCPD() .getValue( getEventValuesForXiGivenParents(Xi, fd.getValueAt(i), event))
cprob; }
return Util.normalize(X); }`
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aimacode/aima-java/issues/245#issuecomment-288403502, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0DuzQnEDp0z_mBSRLxsORAGrgJtWfzks5roSbjgaJpZM4Lhf1X .
Fix in #305.
There might be an error in the GibbsAsk implementation. Evidence for child nodes is ignored. RejectionSampling and Likelyhoodweighting work as expected. Test follows: