|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cc.mallet.grmm.types.CPT
public class CPT
$Id: CPT.java,v 1.1 2007/10/22 21:37:44 mccallum Exp $
Constructor Summary | |
---|---|
CPT(DiscreteFactor subFactor,
Variable child)
|
Method Summary | |
---|---|
boolean |
almostEquals(Factor p)
Returns whether this is almost equal to another potential. |
boolean |
almostEquals(Factor p,
double epsilon)
|
int |
argmax()
Returns the assignment that maximizes this potential. |
AssignmentIterator |
assignmentIterator()
Returns an iterator over all Assignmentss to this potential. |
AbstractTableFactor |
asTable()
|
boolean |
containsVar(Variable var)
Returns whether the potential is over the given variable. |
void |
divideBy(Factor pot)
Computes this /= pot |
java.lang.String |
dumpToString()
|
Factor |
duplicate()
|
double |
entropy()
Returns the expected log factor value, i.e., sum_x factor.value(x) * Math.log (factor.value (x)) where the summation is taken over all passible assignments. |
void |
exponentiate(double power)
|
Factor |
extractMax(java.util.Collection vars)
Returns a potential phi over the given variables obtained by taking phi (x) = max_[all v that contain x] this.prob (x) |
Factor |
extractMax(Variable var)
Returns a potential phi over the given variables obtained by taking phi (x) = max_[all v that contain x] this.prob (x) |
Factor |
extractMax(Variable[] vars)
Returns a potential phi over the given variables obtained by taking phi (x) = max_[all v that contain x] this.prob (x) |
Variable |
getChild()
|
VarSet |
getParents()
|
Variable |
getVariable(int i)
|
int |
indexAtLocation(int loc)
|
boolean |
isNaN()
|
double |
logValue(Assignment assn)
|
double |
logValue(AssignmentIterator it)
|
double |
logValue(int loc)
|
Factor |
marginalize(java.util.Collection vars)
Returns the marginal of this distribution over the given variables. |
Factor |
marginalize(Variable var)
Returns the marginal of this distribution over one variable. |
Factor |
marginalize(Variable[] vars)
Returns the marginal of this distribution over the given variables. |
Factor |
marginalizeOut(Variable var)
Returns the marginal distribution attained by summing out the given variable. |
Factor |
marginalizeOut(VarSet varset)
Returns the marginal distribution attained by summing out the given set of variables. |
Factor |
multiply(Factor dist)
Returns the elementwise product of this factor with another. |
void |
multiplyBy(Factor pot)
Does this *= pot. |
Factor |
normalize()
Multiplies this potential by a constant such that it sums to 1. |
int |
numLocations()
|
java.lang.String |
prettyOutputString()
|
Assignment |
sample(Randoms r)
Return an assignment sampled from this factor, interpreting it as an unnormalized probability distribution. |
int |
sampleLocation(Randoms r)
|
void |
setSubFactor(DiscreteFactor subFactor)
|
int |
singleIndex(int[] smallDims)
|
Factor |
slice(Assignment assn)
|
double |
sum()
Returns the sum of this potential over all cases. |
java.lang.String |
toString()
|
double[] |
toValueArray()
|
double |
value(Assignment assn)
Returns the value of the local function for a given assignment. |
double |
value(AssignmentIterator it)
Returns the probability of an assignment to these variables. |
double |
value(int index)
|
double |
valueAtLocation(int loc)
|
VarSet |
varSet()
Returns set of variables in this potential. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CPT(DiscreteFactor subFactor, Variable child)
Method Detail |
---|
public VarSet getParents()
public Variable getChild()
public void setSubFactor(DiscreteFactor subFactor)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String prettyOutputString()
prettyOutputString
in interface Factor
public double value(Assignment assn)
Factor
value
in interface Factor
public double value(AssignmentIterator it)
Factor
This can be used to do things like
DiscretePotential phi = createMyPtl (); for (AssignmentIterator it = phi.assignmentIterator; it.hasNext(); it.advance()) { double val = ptl.phi (it); // do something with val }
This is equivalent to creating an assignment object explicitly using (Assignment) it.next(), but can be much faster.
value
in interface Factor
public Factor normalize()
Factor
normalize
in interface Factor
public Factor marginalize(Variable[] vars)
Factor
marginalize
in interface Factor
public Factor marginalize(java.util.Collection vars)
Factor
marginalize
in interface Factor
public Factor marginalize(Variable var)
Factor
marginalize
in interface Factor
public Factor marginalizeOut(Variable var)
Factor
marginalizeOut
in interface Factor
public Factor extractMax(java.util.Collection vars)
Factor
extractMax
in interface Factor
public Factor extractMax(Variable var)
Factor
extractMax
in interface Factor
public Factor extractMax(Variable[] vars)
Factor
extractMax
in interface Factor
public int argmax()
Factor
argmax
in interface Factor
public Assignment sample(Randoms r)
Factor
sample
in interface Factor
public double sum()
Factor
sum
in interface Factor
public double entropy()
Factor
entropy
in interface Factor
public Factor multiply(Factor dist)
Factor
multiply
in interface Factor
public void multiplyBy(Factor pot)
Factor
If both potentials are currently in log space, then does addition instead.
multiplyBy
in interface Factor
public void exponentiate(double power)
exponentiate
in interface Factor
public void divideBy(Factor pot)
Factor
If both potentials are currently in log space, then does subtraction instead.
divideBy
in interface Factor
public boolean containsVar(Variable var)
Factor
containsVar
in interface Factor
public VarSet varSet()
Factor
varSet
in interface Factor
public AssignmentIterator assignmentIterator()
Factor
assignmentIterator
in interface Factor
public boolean almostEquals(Factor p)
Factor
almostEquals
in interface Factor
public boolean almostEquals(Factor p, double epsilon)
almostEquals
in interface Factor
public Factor duplicate()
duplicate
in interface Factor
public boolean isNaN()
isNaN
in interface Factor
public double logValue(AssignmentIterator it)
logValue
in interface Factor
public double logValue(Assignment assn)
logValue
in interface Factor
public double logValue(int loc)
logValue
in interface Factor
public Variable getVariable(int i)
getVariable
in interface Factor
public int sampleLocation(Randoms r)
sampleLocation
in interface DiscreteFactor
public double value(int index)
value
in interface DiscreteFactor
public int numLocations()
numLocations
in interface DiscreteFactor
public double valueAtLocation(int loc)
valueAtLocation
in interface DiscreteFactor
public int indexAtLocation(int loc)
indexAtLocation
in interface DiscreteFactor
public double[] toValueArray()
toValueArray
in interface DiscreteFactor
public int singleIndex(int[] smallDims)
singleIndex
in interface DiscreteFactor
public java.lang.String dumpToString()
dumpToString
in interface Factor
public Factor slice(Assignment assn)
slice
in interface Factor
public AbstractTableFactor asTable()
asTable
in interface Factor
public Factor marginalizeOut(VarSet varset)
Factor
marginalizeOut
in interface Factor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |