COM.hugin.HAPI
Class Table

java.lang.Object
  extended byCOM.hugin.HAPI.Table

public class Table
extends java.lang.Object

Hugin uses Tables for representing the conditional probability and utility potentials of individual Nodes, the probability and utility potentials on separators and Cliques of JunctionTrees, evidence potentials, etc.

A potential is a function from the state space of a set of variables into the set of real numbers. A Table is a representation of a potential.


Method Summary
 void delete()
          Deletes this Table.
 int getCGSize()
          Returns the CG size of this Table.
 void getConfiguration(int[] configuration, int index)
          Computes the state configuration corresponding to a given table index.
 double getCovariance(int i, ContinuousChanceNode node1, ContinuousChanceNode node2)
          Returns the covariance of a couple of ContinuousChanceNodes given a configuration of the discrete chance Nodes of this Table.
 double[] getData()
          Returns an array containing a copy of the discrete data of this Table.
 void getData(double[] data, int start, int count)
          Returns a region of the discrete data of this Table.
 double getDataItem(int index)
          Returns the data item at position index of the discrete data of this Table.
 int getIndex(int[] configuration)
          Computes the table index corresponding to a given state configuration.
 double getMean(int i, ContinuousChanceNode node)
          Returns the mean of a ContinuousChanceNode given a configuration of the discrete chance Nodes of this Table.
 NodeList getNodes()
          Returns a NodeList containing the Nodes associated with this Table.
 int getSize()
          Returns the size of this Table.
 double getVariance(int i, ContinuousChanceNode node)
          Returns the variance of a ContinuousChanceNode given a configuration of the discrete chance Nodes of this Table.
 boolean isAlive()
          Is this Table object alive?
 void reorderNodes(NodeList nodes)
          Reorders the list of Nodes of this Table.
 void setData(double[] data)
          Sets the discrete data of this Table.
 void setData(double[] data, int start, int count)
          Sets a region of the discrete data of this Table.
 void setDataItem(int index, double value)
          Sets a specific data item of the discrete data of this Table.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getConfiguration

public void getConfiguration(int[] configuration,
                             int index)
                      throws ExceptionHugin
Computes the state configuration corresponding to a given table index. The computed state configuration is stored in the configuration array: The state index for the k'th node in the node list (see the getNodes() method) of this Table (if the node is discrete) is stored in the k'th entry of the array. The length of the array must be greater than or equal to the number of discrete nodes of this Table (extra entries are ignored).

Throws:
ExceptionHugin

getIndex

public int getIndex(int[] configuration)
             throws ExceptionHugin
Computes the table index corresponding to a given state configuration. The state configuration is specified in the configuration array: A state index for the k'th node in the node list (see the getNodes() method) of this Table (if the node is discrete) must be specified in the k'th entry of the array. The length of the array must be greater than or equal to the number of discrete nodes of this Table (extra entries are ignored).

Throws:
ExceptionHugin

getData

public double[] getData()
                 throws ExceptionHugin
Returns an array containing a copy of the discrete data of this Table. The array is a row-major representation of the actual multi-dimensional data. Note that this is a copy of the real data stored in the table. To update the table, the modified data must be copied back using the setData method.

Throws:
ExceptionHugin

getData

public void getData(double[] data,
                    int start,
                    int count)
             throws ExceptionHugin
Returns a region of the discrete data of this Table. The region is specified by a start position and the number of elements (count) to copy. The data is copied to the data array. Note that since this is a copy of the real data stored in the table, updates will only take place when the data is copied back using the setData method.

The indexes start, ..., start+count-1 must be valid indexes of this table. Also, count must be less than or equal to the size of the data array.

Parameters:
data - array to hold the extracted data
start - index of the first element to copy
count - number of elements to copy
Throws:
ExceptionHugin

getDataItem

public double getDataItem(int index)
                   throws ExceptionHugin
Returns the data item at position index of the discrete data of this Table. The index is interpreted as the index of a one-dimensional row-major representation of the actual multi-dimensional data.

Parameters:
index - the index of the data item
Returns:
The data item at the specified index.
Throws:
ExceptionHugin

getNodes

public NodeList getNodes()
                  throws ExceptionHugin
Returns a NodeList containing the Nodes associated with this Table.

Returns:
A NodeList.
Throws:
ExceptionHugin

getSize

public int getSize()
            throws ExceptionHugin
Returns the size of this Table.

Throws:
ExceptionHugin

getCGSize

public int getCGSize()
              throws ExceptionHugin
Returns the CG size of this Table. This is the number of CG data elements stored in the table.

Throws:
ExceptionHugin

setData

public void setData(double[] data)
             throws ExceptionHugin
Sets the discrete data of this Table. The contents of the data array are copied to the table. The size of the array must equal the size of the table.

Parameters:
data - array holding the data to copy to the table
Throws:
ExceptionHugin

setData

public void setData(double[] data,
                    int start,
                    int count)
             throws ExceptionHugin
Sets a region of the discrete data of this Table. The region is specified by a start position and the number of elements (count) to copy. The data is copied from the data array to the table.

The indexes start, ..., start+count-1 must be valid indexes of this table. Also, count must be less than or equal to the size of the data array.

Parameters:
data - array holding the data to copy to this table
start - index of the first element to be set
count - number of elements to copy
Throws:
ExceptionHugin

setDataItem

public void setDataItem(int index,
                        double value)
                 throws ExceptionHugin
Sets a specific data item of the discrete data of this Table.

Parameters:
index - index of the data item to set
value - the new value of the data item at the specified index.
Throws:
ExceptionHugin

getVariance

public double getVariance(int i,
                          ContinuousChanceNode node)
                   throws ExceptionHugin
Returns the variance of a ContinuousChanceNode given a configuration of the discrete chance Nodes of this Table.

Parameters:
i - the index of the discrete configuration.
node - the ContinuousChanceNode in question.
Returns:
A double-precision real value.
Throws:
ExceptionHugin

getMean

public double getMean(int i,
                      ContinuousChanceNode node)
               throws ExceptionHugin
Returns the mean of a ContinuousChanceNode given a configuration of the discrete chance Nodes of this Table.

Parameters:
i - the index of the discrete configuration.
node - the ContinuousChanceNode in question.
Returns:
A double-precision real value.
Throws:
ExceptionHugin

getCovariance

public double getCovariance(int i,
                            ContinuousChanceNode node1,
                            ContinuousChanceNode node2)
                     throws ExceptionHugin
Returns the covariance of a couple of ContinuousChanceNodes given a configuration of the discrete chance Nodes of this Table.

Parameters:
i - the index of the discrete configuration.
node1 - one of the ContinuousChanceNodes in question.
node2 - the other ContinuousChanceNode.
Returns:
A double-precision real value.
Throws:
ExceptionHugin

reorderNodes

public void reorderNodes(NodeList nodes)
                  throws ExceptionHugin
Reorders the list of Nodes of this Table.

Parameters:
nodes - the new order (which must be a permutation of the current order) of the Nodes of this Table.
Throws:
ExceptionHugin

delete

public void delete()
            throws ExceptionHugin
Deletes this Table. Tables owned by an application should be deleted using this method.

Throws:
ExceptionHugin

isAlive

public boolean isAlive()
Is this Table object alive?