|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cc.mallet.grmm.types.AbstractFactor
public abstract class AbstractFactor
An Abstract class from which new Factor classes can be subclassed. Created: Sep 12, 2005
Field Summary | |
---|---|
protected VarSet |
vars
|
Constructor Summary | |
---|---|
protected |
AbstractFactor()
|
protected |
AbstractFactor(VarSet vars)
|
Method Summary | |
---|---|
boolean |
almostEquals(Factor p)
Returns whether this is almost equal to another potential. |
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 |
delogify()
|
void |
divideBy(Factor pot)
Computes this /= pot |
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) |
protected abstract Factor |
extractMaxInternal(VarSet varSet)
|
Variable |
getVariable(int i)
|
boolean |
isInLogSpace()
|
Factor |
log()
|
void |
logify()
|
double |
logValue(Assignment assn)
|
double |
logValue(AssignmentIterator it)
|
double |
logValue(int loc)
|
protected abstract double |
lookupValueInternal(int i)
|
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. |
protected abstract Factor |
marginalizeInternal(VarSet varsToKeep)
|
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. |
double |
phi(cc.mallet.grmm.types.DenseAssignmentIterator it)
|
java.lang.String |
prettyOutputString()
|
Assignment |
sample(Randoms r)
Return an assignment sampled from this factor, interpreting it as an unnormalized probability distribution. |
protected void |
setVarSet(VarSet vars)
|
double |
sum()
Returns the sum of this potential over all cases. |
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. |
VarSet |
varSet()
Returns set of variables in this potential. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface cc.mallet.grmm.types.Factor |
---|
almostEquals, dumpToString, duplicate, isNaN, normalize, slice |
Field Detail |
---|
protected VarSet vars
Constructor Detail |
---|
protected AbstractFactor()
protected AbstractFactor(VarSet vars)
Method Detail |
---|
protected abstract Factor extractMaxInternal(VarSet varSet)
protected abstract double lookupValueInternal(int i)
protected abstract Factor marginalizeInternal(VarSet varsToKeep)
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 double phi(cc.mallet.grmm.types.DenseAssignmentIterator it)
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 marginalizeOut(VarSet varset)
Factor
marginalizeOut
in interface Factor
public Factor extractMax(Variable[] vars)
Factor
extractMax
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 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 isInLogSpace()
public void logify()
public void delogify()
public Factor log()
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 double logValue(Assignment assn)
logValue
in interface Factor
public double logValue(AssignmentIterator it)
logValue
in interface Factor
public double logValue(int loc)
logValue
in interface Factor
public Variable getVariable(int i)
getVariable
in interface Factor
public AbstractTableFactor asTable()
asTable
in interface Factor
protected void setVarSet(VarSet vars)
public java.lang.String prettyOutputString()
prettyOutputString
in interface Factor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |