|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cc.mallet.grmm.types.AbstractTableFactor
public abstract class AbstractTableFactor
Class for a multivariate multinomial distribution.
Created: Mon Sep 15 17:19:24 2003
Field Summary | |
---|---|
protected Matrix |
probs
|
Constructor Summary | |
---|---|
|
AbstractTableFactor()
Creates an identity potential over NO variables. |
|
AbstractTableFactor(AbstractTableFactor in)
Copy constructor. |
|
AbstractTableFactor(AbstractTableFactor ptl,
double[] probs)
Creates a potential with the same variables as another, but different probabilites. |
protected |
AbstractTableFactor(BidirectionalIntObjectMap varMap)
|
|
AbstractTableFactor(java.util.Collection allVars)
Creates an identity potential with the given variables. |
|
AbstractTableFactor(Variable var)
Creates an identity potential over the given variable. |
|
AbstractTableFactor(Variable[] allVars)
Creates an identity potential with the given variables. |
|
AbstractTableFactor(Variable[] allVars,
double[] probs)
Creates a potential with the given variables and the given probabilities. |
|
AbstractTableFactor(Variable[] allVars,
Matrix probsIn)
Creates a potential with the given variables and the given probabilities. |
|
AbstractTableFactor(Variable var,
double[] values)
|
|
AbstractTableFactor(VarSet allVars,
double[] probs)
Creates a potential with the given variables and the given probabilities. |
|
AbstractTableFactor(VarSet allVars,
Matrix probsIn)
Creates a potential with the given variables and the given probabilities. |
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()
|
java.lang.Object |
clone()
|
boolean |
containsVar(Variable var)
Returns true iff this potential is over the given variable |
protected abstract AbstractTableFactor |
createBlankSubset(Variable[] vars)
|
void |
divideBy(double v)
|
void |
divideBy(Factor pot)
Does the conceptual equivalent of this /= pot. |
protected abstract void |
divideByInternal(DiscreteFactor ptl)
|
java.lang.String |
dumpToString()
|
abstract Factor |
duplicate()
|
protected DiscreteFactor |
ensureOperandCompatible(DiscreteFactor ptl)
Ensures that this.inLogSpace == ptl.inLogSpace. |
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. |
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 |
findVariable(java.lang.String name)
|
abstract Matrix |
getLogValueMatrix()
|
protected int |
getNumVars()
|
abstract Matrix |
getValueMatrix()
|
double[] |
getValues()
|
Variable |
getVariable(int i)
|
int |
indexAtLocation(int loc)
|
boolean |
isNaN()
|
double |
logsum()
|
static Factor |
makeIdentityFactor(AbstractTableFactor copy)
STATIC FACTORY METHODS |
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(AbstractTableFactor result)
|
Factor |
marginalizeOut(Variable var)
Returns the marginal distribution attained by summing out the given variable. |
Factor |
marginalizeOut(VarSet badVars)
Returns the marginal distribution attained by summing out the given set of variables. |
Factor |
multiply(Factor dist)
Returns the elementwise product of this potential and another one. |
void |
multiplyBy(Factor pot)
Does the conceptual equivalent of this *= pot. |
protected abstract void |
multiplyByInternal(DiscreteFactor ptl)
|
abstract Factor |
normalize()
Multiplies this potential by a constant such that it sums to 1. |
int |
numLocations()
|
void |
plusEquals(double v)
Adds a constant to all values in the table. |
void |
plusEquals(Factor f)
|
protected abstract void |
plusEqualsAtLocation(int loc,
double v)
|
protected abstract void |
plusEqualsInternal(DiscreteFactor ptl)
|
java.lang.String |
prettyOutputString()
|
void |
printSizes()
|
void |
printValues()
|
protected abstract double |
rawValue(int singleIdx)
|
abstract AbstractTableFactor |
recenter()
Multiplies this factor by the constant 1/max(). |
Assignment |
sample(Randoms r)
Return an assignment sampled from this factor, interpreting it as an unnormalized probability distribution. |
int |
sampleLocation(Randoms r)
|
abstract void |
setLogValue(Assignment assn,
double logValue)
Use of this method is discouraged. |
abstract void |
setLogValue(AssignmentIterator assnIt,
double logValue)
Use of this method is discouraged. |
abstract void |
setLogValues(double[] vals)
|
void |
setRawValue(Assignment assn,
double value)
|
void |
setRawValue(AssignmentIterator it,
double value)
|
protected void |
setRawValue(int loc,
double value)
|
abstract void |
setValue(AssignmentIterator assnIt,
double logValue)
Use of this method is discouraged. |
abstract void |
setValues(double[] vals)
|
void |
setValues(Matrix probs)
|
int |
singleIndex(int[] smallDims)
|
protected abstract Factor |
slice_general(Variable[] vars,
Assignment observed)
|
protected abstract Factor |
slice_onevar(Variable var,
Assignment observed)
|
protected abstract Factor |
slice_twovar(Variable v1,
Variable v2,
Assignment observed)
|
Factor |
slice(Assignment assn)
Creates a new potential that is equal to this one, restricted to a given assignment. |
abstract double |
sum()
Returns the sum of this potential over all cases. |
abstract void |
timesEquals(double v)
Multiplies a constant by all values in the table. |
double[] |
toLogValueArray()
|
java.lang.String |
toString()
|
double[] |
toValueArray()
|
abstract double |
value(Assignment assn)
Returns the value of the local function for a given assignment. |
VarSet |
varSet()
Returns set of variables in this potential. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface cc.mallet.grmm.types.DiscreteFactor |
---|
value, valueAtLocation |
Methods inherited from interface cc.mallet.grmm.types.Factor |
---|
exponentiate, logValue, logValue, logValue, value |
Field Detail |
---|
protected Matrix probs
Constructor Detail |
---|
protected AbstractTableFactor(BidirectionalIntObjectMap varMap)
public AbstractTableFactor(Variable var)
public AbstractTableFactor(Variable var, double[] values)
public AbstractTableFactor()
public AbstractTableFactor(Variable[] allVars)
public AbstractTableFactor(java.util.Collection allVars)
allVars
- A collection containing the Variables
of this distribution.public AbstractTableFactor(Variable[] allVars, double[] probs)
allVars
- Variables of the potentialprobs
- All phi values of the potential, in row-major order.public AbstractTableFactor(VarSet allVars, double[] probs)
allVars
- Variables of the potentialprobs
- All phi values of the potential, in row-major order.public AbstractTableFactor(Variable[] allVars, Matrix probsIn)
allVars
- Variables of the potentialprobsIn
- All the phi values of the potential.public AbstractTableFactor(AbstractTableFactor in)
public AbstractTableFactor(VarSet allVars, Matrix probsIn)
allVars
- Variables of the potentialprobsIn
- All the phi values of the potential.public AbstractTableFactor(AbstractTableFactor ptl, double[] probs)
ptl
- probs
- Method Detail |
---|
public static Factor makeIdentityFactor(AbstractTableFactor copy)
public abstract Factor duplicate()
duplicate
in interface Factor
public abstract Factor normalize()
Factor
normalize
in interface Factor
public abstract double sum()
Factor
sum
in interface Factor
protected abstract AbstractTableFactor createBlankSubset(Variable[] vars)
protected int getNumVars()
public void setValues(Matrix probs)
public boolean containsVar(Variable var)
containsVar
in interface Factor
public VarSet varSet()
varSet
in interface Factor
public AssignmentIterator assignmentIterator()
Factor
assignmentIterator
in interface Factor
public void setRawValue(Assignment assn, double value)
public void setRawValue(AssignmentIterator it, double value)
protected void setRawValue(int loc, double value)
public abstract double value(Assignment assn)
Factor
value
in interface Factor
public double logsum()
public double entropy()
Factor
entropy
in interface Factor
public Factor marginalize(Variable[] vars)
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 badVars)
Factor
marginalizeOut
in interface Factor
protected abstract Factor marginalizeInternal(AbstractTableFactor result)
public Factor extractMax(Variable var)
Factor
extractMax
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 void multiplyBy(Factor pot)
multiplyBy
in interface Factor
protected DiscreteFactor ensureOperandCompatible(DiscreteFactor ptl)
ptl
-
protected abstract void multiplyByInternal(DiscreteFactor ptl)
protected abstract void plusEqualsInternal(DiscreteFactor ptl)
public Factor multiply(Factor dist)
multiply
in interface Factor
public void divideBy(Factor pot)
divideBy
in interface Factor
protected abstract void divideByInternal(DiscreteFactor ptl)
public int argmax()
Factor
argmax
in interface Factor
public Assignment sample(Randoms r)
Factor
sample
in interface Factor
public int sampleLocation(Randoms r)
sampleLocation
in interface DiscreteFactor
public boolean almostEquals(Factor p)
Factor
almostEquals
in interface Factor
public boolean almostEquals(Factor p, double epsilon)
almostEquals
in interface Factor
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String dumpToString()
dumpToString
in interface Factor
public boolean isNaN()
isNaN
in interface Factor
public void printValues()
public void printSizes()
public Variable findVariable(java.lang.String name)
public int numLocations()
numLocations
in interface DiscreteFactor
public int indexAtLocation(int loc)
indexAtLocation
in interface DiscreteFactor
public Variable getVariable(int i)
getVariable
in interface Factor
public void divideBy(double v)
public abstract void setLogValue(Assignment assn, double logValue)
public abstract void setLogValue(AssignmentIterator assnIt, double logValue)
public abstract void setValue(AssignmentIterator assnIt, double logValue)
protected abstract double rawValue(int singleIdx)
public double[] toValueArray()
toValueArray
in interface DiscreteFactor
public int singleIndex(int[] smallDims)
singleIndex
in interface DiscreteFactor
public abstract Matrix getValueMatrix()
public abstract Matrix getLogValueMatrix()
public abstract void setLogValues(double[] vals)
public abstract void setValues(double[] vals)
public double[] toLogValueArray()
public double[] getValues()
public void plusEquals(double v)
public void plusEquals(Factor f)
public abstract void timesEquals(double v)
protected abstract void plusEqualsAtLocation(int loc, double v)
public abstract AbstractTableFactor recenter()
public AbstractTableFactor asTable()
asTable
in interface Factor
public Factor slice(Assignment assn)
slice
in interface Factor
assn
- Variables to hold as fixed
protected abstract Factor slice_onevar(Variable var, Assignment observed)
protected abstract Factor slice_twovar(Variable v1, Variable v2, Assignment observed)
protected abstract Factor slice_general(Variable[] vars, Assignment observed)
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 |