const prob_bn* GetNodeProbs_bn ( const node_bn*  node,   const state_bn*  parent_states )

Returns the conditional probabilities of node, given that its parents are in the states indicated by the parent_states vector, by looking them up in the node's CPT table. The length of parent_states must be the number of parents of node, and each of its entries provides a state for the corresponding parent. The length of the array returned is the number of states of node, and consists of 'prob_bn's (i.e. 'float's), which are the conditional probabilities:

P (node = state0 | parents take on parent_states)

P (node = state1 | parents take on parent_states)

...

P (node = stateN | parents take on parent_states)

Notice that it is not conditioned on any findings (evidence) entered into the net, so its value will not change as findings are added or belief updating is done.

NULL will be returned if no CPT table has been associated with node (for example by SetNodeProbs_bn, SetNodeFuncState_bn, EquationToTable_bn, ReviseCPTsByCaseFile_bn or ReviseCPTsByFindings_bn), or if the table has been removed (for example by DeleteNodeTables_bn), but no error will be generated. If you use only SetNodeEquation_bn to indicate a node's relation with its parents, you must also call EquationToTable_bn before this will return non-NULL.

The order of the states in parent_states should match the order of the nodes in the list returned by GetNodeParents_bn (this will be the same order that parents were added using AddLink_bn). MapStateList_bn may be useful for that. parent_states can be NULL if node has no parents.

parent_states should not include EVERY_STATE or UNDEF_STATE.

If SetNodeFuncState_bn was used to provide node with a function table, then GetNodeProbs_bn can be used to retrieve that table in the form of conditional probabilities, which will all be 0 or 1.

If you need the results to persist, make a copy of the vector returned, since its contents may become invalid after further calls to Netica API. Do not try to directly modify or free the vector returned.

To get all the conditional probabilities of node at once, see the GetNodeAllProbs example below.

To cycle through all the possibilities of parent_states, see the NeticaEx function NextStates.

If parent_states is NULL then the entire table is returned.

Version:

This function is available in all versions.

 SetNodeProbs_bn Sets them HasNodeTable_bn Determine if GetNodeProbs_bn is going to return NULL GetNodeBeliefs_bn Conditioned on findings, but not parents AbsorbNodes_bn Can be used to find probabilities conditioned on parents and findings GetNodeFuncState_bn For deterministic nodes GetNodeExperience_bn The confidence of the probabilities obtained GetNodeParents_bn Indicates the order of entries in parent_states GetNodeNumberStates_bn Length of the array returned (plus one if node continuous) MapStateList_bn To create the state list passed in

Example:

```// To just get the probability that node is in state, given parent_states
//
double prob = GetNodeProbs_bn (node, parent_states) [state];```
Example 2:
```The following function is available in NeticaEx.c:
// Puts all the conditional probabilities of node into the array probs.
// You could allocate probs as follows (SizeCartesianProduct is defined
// in NeticaEx.c):
//   probs = malloc (SizeCartesianProduct (GetNodeParents_bn (node)) *
//                   GetNodeNumberStates_bn (node) * sizeof (prob_bn));
//
void GetNodeAllProbs (node_bn* node, prob_bn* probs){
nodelist_bn* parents = GetNodeParents_bn (node);
int num_states  = GetNodeNumberStates_bn (node);
int num_parents = LengthNodeList_bn (parents);
state_bn st, *parent_states = calloc (num_parents, sizeof (state_bn));
while (1){
const prob_bn* vecp = GetNodeProbs_bn (node, parent_states);
if (!vecp)  break;
for (st = 0;  st < num_states;  ++st)  *probs++ = *vecp++;
if (NextStates (parent_states, parents))          // defined in NeticaEx.c
break;
if (GetError_ns (env, ERROR_ERR, NULL))  break;
}
free (parent_states);
}```