edu.cs.ai.kreator.logic.probabilities
Class Cpd

java.lang.Object
  extended by edu.cs.ai.kreator.logic.probabilities.Cpd

public class Cpd
extends java.lang.Object

This class models a conditional probability table for a bayesian clause. Mainly, a CPD is composed of a map from the different instantiation of the clause to a probability. Suppose a bayesian clause has the form A | A1,...,Ak, then the keys of the map encoded in this CPD have size k+1 and the key "a0,a1,...,ak" (as a list of strings) is associated with the conditional probability P(A=a0|A1=a1,...,Ak=ak).

Author:
Matthias Thimm

Field Summary
static org.apache.log4j.Logger LOG
           
 
Constructor Summary
Cpd()
          Constructs an empty cpd
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.Double get(java.util.List<java.lang.String> key)
           
static Cpd getCombinedCPD(java.util.List<Cpd> cpds)
          Computes all possible key combinations of the given cpds and combines them into one common cpd
 int hashCode()
           
 java.util.Set<java.util.List<java.lang.String>> keySet()
           
 void normalize(boolean conditional)
          This method normalizes this CPD, i.e., if the sum of the values of this cpd is different to one, it adjusts the values appropriately to sum to one.
 java.lang.Double put(java.util.List<java.lang.String> key, java.lang.Double value)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Constructor Detail

Cpd

public Cpd()
Constructs an empty cpd

Method Detail

getCombinedCPD

public static Cpd getCombinedCPD(java.util.List<Cpd> cpds)
Computes all possible key combinations of the given cpds and combines them into one common cpd

Parameters:
cpds - a list of cpds
Returns:
a cpd

normalize

public void normalize(boolean conditional)
This method normalizes this CPD, i.e., if the sum of the values of this cpd is different to one, it adjusts the values appropriately to sum to one.

Parameters:
conditional - specifies of this CPD truly models a conditional probability table, i.e., whether the values of all keys that are the same expect the first element should sum up to one or whether the values of all keys should sum up to one. Set to "true" if this CPD models a truly conditional probability table, such that all values of the same keys except the first element should sum up to one.

get

public java.lang.Double get(java.util.List<java.lang.String> key)

put

public java.lang.Double put(java.util.List<java.lang.String> key,
                            java.lang.Double value)

keySet

public java.util.Set<java.util.List<java.lang.String>> keySet()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object