 Author Topic: Check the results of an expression  (Read 9677 times) novaczkisz

• Newbie
• • Posts: 5 Check the results of an expression
« on: April 01, 2010, 17:15:46 »
Hi!

I built up a very simple network:
Three nodes (A,B,C). Node A nd B are the parents of C. The CPT values of node A and B are added manually and the CPT of node C should be filled by a simple expression: A+B. I can build the network, set the CPTs manually and configure the expression for node C. The network can be comlied an runned. The belief values of each node is showed in run mode.

Thats nice but: My question is that where do the belief values come from for node C (i do not mean here marginalization, but the input for it)? In edit mode i try to get the CPT of node C but instead of probability vaues (that should be the input for marginalizationj) i see only question-marks (?). A further question arises than: what exaxtly does the A+B expression? Or put it in an other way: What does the CPT of node C look like if the CPT of node A and B looks like this and the expressin for node C is A+B:

A:
0: 0.1
1: 0.2
2: 0.7

B:
0: 0.2
1: 0.2
2: 0.6

C: Thx and br.
Szabolcs Anders L Madsen

• HUGIN Expert
• Hero Member
•     • Posts: 2285 Re: Check the results of an expression
« Reply #1 on: April 01, 2010, 19:28:48 »
An addition expression can be used to generate the CPT of a numeric node by applying the expression to each configuration of the parent nodes and mapping the resulting value to the corresponding state of the child.

In your example the CPT of C is computed from the expression A + B as follows
A, B, C
0 + 0 = 0
0 + 1 = 1
0 + 2 = 2
et cetera

The table is created once the domain is compiled. You can generate the CPT from the expression by selecting "Functions->Expressions->Show as table" in the Table view.

You should read the tutorial on the table generator in the HTML help of the GUI.
HUGIN EXPERT A/S novaczkisz

• Newbie
• • Posts: 5 Re: Check the results of an expression
« Reply #2 on: April 02, 2010, 07:33:14 »
Hi!

Thx for the quick answer!

If it should work like you say than there is a bug here or (most probably) i still dont get it After compiling the network i have the following code in the .net file:

Code: [Select]
potential (C | B A)
{
model_nodes = ();
model_data = ( A + B );
data
= ((( 1 0 0 0 0 ) %  B=0  A=0
( 0 1 0 0 0 ) %  B=0  A=1
( 0 0 1 0 0 )) %  B=0  A=2
(( 0 1 0 0 0 ) %  B=1  A=0
( 0 0 1 0 0 ) %  B=1  A=1
( 0 0 0 1 0 )) %  B=1  A=2
(( 0 0 1 0 0 ) %  B=2  A=0
( 0 0 0 1 0 ) %  B=2  A=1
( 0 0 0 0 1 ))); %  B=2  A=2
}

This does not fit in your explanation, doesn't it?

Thx and br,
Szabolcs Anders L Madsen

• HUGIN Expert
• Hero Member
•     • Posts: 2285 Re: Check the results of an expression
« Reply #3 on: April 02, 2010, 15:47:21 »
Hi

I assume C has states space 0,1,2,3,4. In this case each configuration of A and B maps to the state of C. The you should read the potential as illustated below

((( 1 0 0 0 0 )   %  B=0  A=0 - C is in state wih index 0 (i.e., C = 0)
( 0 1 0 0 0 )   %  B=0  A=1 - C is in state wih index 1 (i.e., C = 1)
( 0 0 1 0 0 ))   %  B=0  A=2 - C is in state wih index 2 (i.e., C = 2)
(( 0 1 0 0 0 )   %  B=1  A=0 - C is in state wih index 1 (i.e., C = 1)
( 0 0 1 0 0 )   %  B=1  A=1 - C is in state wih index 2 (i.e., C = 2)
( 0 0 0 1 0 ))   %  B=1  A=2 - C is in state wih index 3 (i.e., C = 3)
(( 0 0 1 0 0 )   %  B=2  A=0 - C is in state wih index 2 (i.e., C = 2)
( 0 0 0 1 0 )   %  B=2  A=1 - C is in state wih index 3 (i.e., C = 3)
( 0 0 0 0 1 )));   %  B=2  A=2 - C is in state wih index 4 (i.e., C = 4)

Each vector is a probability distribution over the states of C. As C = A+B this corresponds to a deterministic function where C is "instantiated" to the state corresponding to the sum of its parents.

This fits with the explanation.
HUGIN EXPERT A/S novaczkisz

• Newbie
• • Posts: 5 Re: Check the results of an expression
« Reply #4 on: April 03, 2010, 11:34:56 »
Hi!

Ok, i get it! Thx for the explanation.

Br,
Szabolcs