Issues with Extracting Conditional Probabilities

The engine.
Post Reply
Bo Hu
Posts: 18
Joined: Tue Aug 02, 2016 4:13 am

Issues with Extracting Conditional Probabilities

Post by Bo Hu »

Hello,

In my network, Node B is set to be dependent on Node A. Both nodes have two states "1" and "0". I use following codes to extract the results of the parameter learning. I want to get all probabilities from the conditional probabilities with respect to Node B: P(B=1|A=1), P(B=0|A=1), P(B=1|A=0) P(B=0|A=0). There seems some problems with my codes because I got the same values for all last three probabilies(P_B_0_A_1=P_B_1_A_0=P_B_0_A_0). This does not make any sense to me. Anything wrong with my codes?

Thanks in advance!
Bo

int B = LIN_4T.FindNode("B");
theCoordinates.LinkTo(*LIN_4T.GetNode(B)->Value());
theCoordinates.GoFirst();
double P_B_1_A_1 = theCoordinates.UncheckedValue();
theCoordinates.Next();
double P_B_0_A_1 = theCoordinates.UncheckedValue();
theCoordinates.Next();
double P_B_1_A_0 = theCoordinates.UncheckedValue();
theCoordinates.Next();
double P_B_0_A_0 = theCoordinates.UncheckedValue();
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Issues with Extracting Conditional Probabilities

Post by shooltz[BayesFusion] »

Your code accesses the posterior probabilities, not the conditionals. Also, I'd suggest using the direct access to DSL_Dmatrix object instead of DSL_sysCoordinates.

Code: Select all

int B = LIN_4T.FindNode("B");
const DSL_Dmatrix* mtx = net.GetNode(B)->Definition()->GetMatrix();
// read the content of mtx using linear index or odometer coords, for example:

for (int i = 0; i < mtx->GetSize(); i ++)
{
  printf("%d %f\n", i, (*mtx)[i]);
}
Post Reply