edu.ucla.belief
Class Table

Object
  extended by Table
All Implemented Interfaces:
CPTInfo.ReadableWritableTable, Potential, Cloneable
Direct Known Subclasses:
TableScaled

public class Table
extends Object
implements Potential, CPTInfo.ReadableWritableTable


Field Summary
static boolean FLAG_DEBUG
           
static boolean FLAG_DEBUG_STATE_MODIFICATION
           
static double ONE
           
static double ZERO
           
 
Constructor Summary
Table(FiniteVariable[] vars)
          Creates a new table that has a TableIndex generated from the variables supplied.
Table(List variables)
          Creates a new table that has a TableIndex generated from the variables supplied.
Table(List variables, double[] values)
          Creates a new table that has a TableIndex generated from the variables supplied.
Table(Object[] vars, double[] values)
          Creates a new table that has a TableIndex generated from the variables supplied.
Table(Table t)
          Creates a copy of the table.
Table(TableIndex index)
          Creates a table with the supplied index.
Table(TableIndex index, double[] values)
          Creates a new Table.
Table(TableIndex index, double[] values, boolean strict)
           
 
Method Summary
 Table add(Table t)
          Could return a Table or TableScaled.
 void addInto(Table t)
           
 void addIntoTrivial(Table that)
           
 void addIntoTrivialScale(Table that, double scalar)
           
 Object clone()
           
 double[] dataclone()
           
static double distanceMeasure(double[] data1, double[] data2)
           
 double distanceMeasure(Table table2)
           
 Table divide(Table t)
           
 void divideInto(Table t)
           
 boolean ensureCPTProperty(FiniteVariable var)
           
 void ensureNonsingular()
           
 double entropy()
           
 boolean epsilonEquals(Table table, double epsilon)
           
 Table expand(FiniteVariable var)
           
 void fill(double value)
           
 Table forget(Set vars)
           
 Table forget(Variable var)
           
 double getCP(int ind)
           
 int getCPLength()
           
 double getCPScaled(int ind)
           
 double getCPScaled(int[] indices)
           
 TableIndex index()
          Returns the TableIndex of this Table.
static Table innerProduct(Table t1, Table t2)
           
 void insertState(int ind)
           
 boolean isSingular()
           
 boolean isValidProbability()
           
 void makeUniform()
           
 double max()
           
 int maxInd()
           
 double min()
           
 Table multiply(Table t2)
           
static Table multiply(Table t1, Table t2)
           
static Table multiplyAll(Set tables)
           
 void multiplyInto(Table t2)
           
static double myLog(double arg)
           
 void normalize()
           
 void normalize(int conditionIndex)
           
static Table normalize(Table t)
           
 void parentStateInserted(FiniteVariable parent, int indexNewInstance)
           
 void parentStateRemoved(FiniteVariable parent, int indexRemovedInstance)
           
 Table permute(FiniteVariable[] order)
           
static void printArr(double[] array, PrintStream stream)
           
static void printArr(double[] array, PrintWriter stream)
           
static void printArr(Table t, PrintStream stream)
           
static void printArr(Table t, PrintWriter stream)
           
static void printArrScaled(double[] array, double scalar)
          Calls TableScaled.toScaled on each value.
static void printArrUnScaled(double[] array, double scalar)
          Calls TableScaled.toRealPr on each value.
 Table project(Set vars)
           
 int random(Map mapInstantions)
           
 void removeState(int ind)
           
 void replaceVariables(Map old2new)
           
 void replaceVariables(Map old2new, boolean partial)
           
 boolean satisfiesCPTProperty(FiniteVariable var, double epsilon)
           
 double scalar()
           
 void scale(double scalar)
           
 void set(Table t)
          Copies the values from another compatible array.
 void setCP(int indx, double val)
           
 void setValue(int[] ind, double val)
          Sets the value of the table entry referenced by ind.
 void setValues(double[] valuesToSet)
           
 Table shrink(Map evidence)
           
static Set shrinkAll(Collection tables, Map evidence)
          102502 Modified to accomodate CPTShell
static double sum(double[] values, int startindex, int endindex)
           
 String tableString()
           
 String tableString(String tab)
           
 String toString()
           
 double value(int[] ind)
          Returns the value of the table entry referenced by ind.
 double value(Object[] instantiations)
           
 ArrayList valueElimination()
          For any variable=state, if all possible combinations of other variables have prob=0, then this state can be removed.
 List variables()
          Returns the variables that this Table contains.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static double ZERO

ONE

public static double ONE

FLAG_DEBUG

public static boolean FLAG_DEBUG

FLAG_DEBUG_STATE_MODIFICATION

public static boolean FLAG_DEBUG_STATE_MODIFICATION
Constructor Detail

Table

public Table(Table t)
Creates a copy of the table. The values stored are replicated, not shared.


Table

public Table(TableIndex index)
Creates a table with the supplied index. All of the values are initialized to 0.


Table

public Table(TableIndex index,
             double[] values)
Creates a new Table.

Parameters:
index - This is used directly (not copied).
values - These are used directly (not copied).

Table

public Table(TableIndex index,
             double[] values,
             boolean strict)
Since:
20060804

Table

public Table(List variables,
             double[] values)
Creates a new table that has a TableIndex generated from the variables supplied.

Parameters:
values - These are used directly (not copied).

Table

public Table(List variables)
Creates a new table that has a TableIndex generated from the variables supplied.


Table

public Table(FiniteVariable[] vars)
Creates a new table that has a TableIndex generated from the variables supplied.


Table

public Table(Object[] vars,
             double[] values)
Creates a new table that has a TableIndex generated from the variables supplied.

Parameters:
values - These are used directly (not copied).
Method Detail

scalar

public double scalar()
Since:
041403

getCPScaled

public double getCPScaled(int ind)

getCPScaled

public double getCPScaled(int[] indices)

isValidProbability

public boolean isValidProbability()
Since:
060602

normalize

public void normalize()
               throws Exception
Throws:
Exception
Since:
110102

normalize

public void normalize(int conditionIndex)
               throws Exception
Throws:
Exception
Since:
110102

sum

public static double sum(double[] values,
                         int startindex,
                         int endindex)
                  throws Exception
Throws:
Exception
Since:
110102

ensureNonsingular

public void ensureNonsingular()
Since:
110102

isSingular

public boolean isSingular()
Since:
110102

makeUniform

public void makeUniform()
Since:
110102

clone

public Object clone()
Specified by:
clone in interface Potential
Overrides:
clone in class Object

replaceVariables

public void replaceVariables(Map old2new)
Since:
20020604

replaceVariables

public void replaceVariables(Map old2new,
                             boolean partial)
Since:
20080220

printArr

public static void printArr(double[] array,
                            PrintWriter stream)
Since:
041403

printArr

public static void printArr(double[] array,
                            PrintStream stream)

printArr

public static void printArr(Table t,
                            PrintWriter stream)
Since:
110603

printArr

public static void printArr(Table t,
                            PrintStream stream)

printArrScaled

public static void printArrScaled(double[] array,
                                  double scalar)
Calls TableScaled.toScaled on each value.


printArrUnScaled

public static void printArrUnScaled(double[] array,
                                    double scalar)
Calls TableScaled.toRealPr on each value.


setValues

public void setValues(double[] valuesToSet)
Since:
050904

dataclone

public double[] dataclone()

getCPLength

public int getCPLength()
Specified by:
getCPLength in interface CPTInfo.ReadableWritableTable

getCP

public double getCP(int ind)
Specified by:
getCP in interface CPTInfo.ReadableWritableTable

setCP

public void setCP(int indx,
                  double val)
Specified by:
setCP in interface CPTInfo.ReadableWritableTable

max

public double max()
Since:
071003

min

public double min()
Since:
010905

random

public int random(Map mapInstantions)
Since:
021704

value

public double value(int[] ind)
Returns the value of the table entry referenced by ind.

Parameters:
ind - The the instance of each variable in the table.

value

public double value(Object[] instantiations)
Since:
100702

setValue

public void setValue(int[] ind,
                     double val)
Sets the value of the table entry referenced by ind.

Parameters:
ind - The the instance of each variable in the table.
val - The value to set the entry to.

index

public TableIndex index()
Returns the TableIndex of this Table.


variables

public List variables()
Returns the variables that this Table contains.

Specified by:
variables in interface Potential

fill

public void fill(double value)

set

public void set(Table t)
Copies the values from another compatible array. The orderings of the two tables must be the same for it to work meaningfully.


toString

public String toString()
Overrides:
toString in class Object

tableString

public String tableString(String tab)
Since:
20040506

tableString

public String tableString()
Since:
20040521

multiplyInto

public void multiplyInto(Table t2)

multiply

public static Table multiply(Table t1,
                             Table t2)

multiply

public Table multiply(Table t2)

multiplyAll

public static Table multiplyAll(Set tables)

expand

public Table expand(FiniteVariable var)

forget

public Table forget(Variable var)

forget

public Table forget(Set vars)

project

public Table project(Set vars)

addInto

public void addInto(Table t)

addIntoTrivial

public void addIntoTrivial(Table that)
Since:
110503

addIntoTrivialScale

public void addIntoTrivialScale(Table that,
                                double scalar)
Since:
110603

scale

public void scale(double scalar)
Since:
110603

add

public Table add(Table t)
Could return a Table or TableScaled.


divideInto

public void divideInto(Table t)

divide

public Table divide(Table t)

shrink

public Table shrink(Map evidence)

shrinkAll

public static Set shrinkAll(Collection tables,
                            Map evidence)
102502 Modified to accomodate CPTShell

Since:
102502

permute

public Table permute(FiniteVariable[] order)

normalize

public static Table normalize(Table t)

innerProduct

public static Table innerProduct(Table t1,
                                 Table t2)

satisfiesCPTProperty

public boolean satisfiesCPTProperty(FiniteVariable var,
                                    double epsilon)

ensureCPTProperty

public boolean ensureCPTProperty(FiniteVariable var)

maxInd

public int maxInd()

insertState

public void insertState(int ind)
Since:
101502

removeState

public void removeState(int ind)
Since:
101502

parentStateInserted

public void parentStateInserted(FiniteVariable parent,
                                int indexNewInstance)
Since:
101502

parentStateRemoved

public void parentStateRemoved(FiniteVariable parent,
                               int indexRemovedInstance)
Since:
101502

valueElimination

public ArrayList valueElimination()
For any variable=state, if all possible combinations of other variables have prob=0, then this state can be removed.


distanceMeasure

public double distanceMeasure(Table table2)

distanceMeasure

public static double distanceMeasure(double[] data1,
                                     double[] data2)

entropy

public double entropy()
Since:
080504

myLog

public static final double myLog(double arg)
Since:
080504

epsilonEquals

public boolean epsilonEquals(Table table,
                             double epsilon)
Since:
081903


Copyright 2010 UCLA Automated Reasoning Group