|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcc.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 Factorpublic double value(AssignmentIterator it)
FactorThis 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 Factorpublic double phi(cc.mallet.grmm.types.DenseAssignmentIterator it)
public Factor marginalize(Variable[] vars)
Factor
marginalize in interface Factorpublic Factor marginalize(java.util.Collection vars)
Factor
marginalize in interface Factorpublic Factor marginalize(Variable var)
Factor
marginalize in interface Factorpublic Factor marginalizeOut(Variable var)
Factor
marginalizeOut in interface Factorpublic Factor marginalizeOut(VarSet varset)
Factor
marginalizeOut in interface Factorpublic Factor extractMax(Variable[] vars)
Factor
extractMax in interface Factorpublic Factor extractMax(java.util.Collection vars)
Factor
extractMax in interface Factorpublic Factor extractMax(Variable var)
Factor
extractMax in interface Factorpublic int argmax()
Factor
argmax in interface Factorpublic Assignment sample(Randoms r)
Factor
sample in interface Factorpublic double sum()
Factor
sum in interface Factorpublic double entropy()
Factor
entropy in interface Factorpublic Factor multiply(Factor dist)
Factor
multiply in interface Factorpublic void multiplyBy(Factor pot)
FactorIf both potentials are currently in log space, then does addition instead.
multiplyBy in interface Factorpublic void exponentiate(double power)
exponentiate in interface Factorpublic void divideBy(Factor pot)
FactorIf both potentials are currently in log space, then does subtraction instead.
divideBy in interface Factorpublic boolean isInLogSpace()
public void logify()
public void delogify()
public Factor log()
public boolean containsVar(Variable var)
Factor
containsVar in interface Factorpublic VarSet varSet()
Factor
varSet in interface Factorpublic AssignmentIterator assignmentIterator()
Factor
assignmentIterator in interface Factorpublic boolean almostEquals(Factor p)
Factor
almostEquals in interface Factorpublic double logValue(Assignment assn)
logValue in interface Factorpublic double logValue(AssignmentIterator it)
logValue in interface Factorpublic double logValue(int loc)
logValue in interface Factorpublic Variable getVariable(int i)
getVariable in interface Factorpublic AbstractTableFactor asTable()
asTable in interface Factorprotected 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 | |||||||||