Data Property | Startpage |
HAPI | HAPI.Table | Data(lIndex As Long) [[As Single]] |
Property Data(lIndex As Long) [[As Single]]
read/write
Name Type Description lIndex
Long Determines the configuration of the discrete nodes of this Table.
This property accesses the discrete part of the function represented by the table. For conditional probability tables of discrete chance nodes and utility tables this property is all you need to edit the table.For Table objects returned from GetMarginal and Distribution, the Data property accessess the joint probability table of all the discrete nodes (see Nodes) of that table.
Example: If you have a discrete chance node A with discrete parents B and C, and each have two states (indexed 0 and 1), you can specify the conditional probability table of A in these few lines of code (see description of Table to understand the indexing of Data):
Set tb = A.Table ' Get the Table object representing the cpt of A.
Set colOrder = New Collection ' Create a collection to specify my own order of the table nodes.
Call colOrder.Add(B)
Call colOrder.Add(C)
Call colOrder.Add(A) ' A must be the last node!
Call tb.ReorderNodes(colOrder)
tb.Data(0) = 0.1 ' B=0, C=0, A=0
tb.Data(1) = 0.9 ' B=0, C=0, A=1
tb.Data(2) = 0.2 ' B=0, C=1, A=0
tb.Data(3) = 0.8 ' B=0, C=1, A=1
tb.Data(4) = 0.3 ' B=1, C=0, A=0
tb.Data(5) = 0.7 ' B=1, C=0, A=1
tb.Data(6) = 0.5 ' B=1, C=1, A=0
tb.Data(7) = 0.5 ' B=1, C=1, A=1In this example all configurations of the parents each sums to 1 (which they should). However, this need not be the case - Hugin will normalize during compilation so that they will. This makes it easier to specify fractions (eg. "tb.Data(0)=1 _ tb.Data(1)=2" would be normalized to 1/3 and 2/3 for configuration 0 and 1 respectively).
![]() |
HUGIN Expert A/S, 2008 - comments to activex@hugin.com |