Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## cc.mallet.grmm.types
Class AbstractFactor

    java.lang.Object
      cc.mallet.grmm.types.AbstractFactor

All Implemented Interfaces:
  Factor, java.io.Serializable, java.lang.Cloneable

Direct Known Subclasses:
  Assignment, BetaFactor, BinaryUnaryFactor, BoltzmannPairFactor, BoltzmannUnaryFactor, ConstantFactor, NormalFactor, PottsTableFactor, SkeletonFactor, UniformFactor, UniNormalFactor

    public abstract class AbstractFactor

extends java.lang.Object
implements Factor

An Abstract class from which new Factor classes can be subclassed. Created: Sep 12, 2005

Version:
  $Id: AbstractFactor.java,v 1.1 2007/10/22 21:37:44 mccallum Exp $
Author:
  Serialized Form

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)`
`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

### vars

    protected VarSet vars

Constructor Detail

### AbstractFactor

    protected AbstractFactor()

### AbstractFactor

    protected AbstractFactor(VarSet vars)

Method Detail

### extractMaxInternal

    protected abstract Factor extractMaxInternal(VarSet varSet)

### lookupValueInternal

    protected abstract double lookupValueInternal(int i)

### marginalizeInternal

    protected abstract Factor marginalizeInternal(VarSet varsToKeep)

### value

    public double value(Assignment assn)

  Description copied from interface: `Factor`
  Returns the value of the local function for a given assignment. All variables in the potential must be included, but it's okay if the assignment uses variables not in the potential.

  Specified by:
    `value` in interface `Factor`

### value

    public double value(AssignmentIterator it)

  Description copied from interface: `Factor`
  Returns the probability of an assignment to these variables. The assignment used is the curret assignment from the given AssignmentIterator.

  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.

  Specified by:
    `value` in interface `Factor`

### phi

    public double phi(cc.mallet.grmm.types.DenseAssignmentIterator it)

### marginalize

    public Factor marginalize(Variable[] vars)

  Description copied from interface: `Factor`
  Returns the marginal of this distribution over the given variables.

  Specified by:
    `marginalize` in interface `Factor`

### marginalize

    public Factor marginalize(java.util.Collection vars)

  Description copied from interface: `Factor`
  Returns the marginal of this distribution over the given variables.

  Specified by:
    `marginalize` in interface `Factor`

### marginalize

    public Factor marginalize(Variable var)

  Description copied from interface: `Factor`
  Returns the marginal of this distribution over one variable.

  Specified by:
    `marginalize` in interface `Factor`

### marginalizeOut

    public Factor marginalizeOut(Variable var)

  Description copied from interface: `Factor`
  Returns the marginal distribution attained by summing out the given variable.

  Specified by:
    `marginalizeOut` in interface `Factor`

### marginalizeOut

    public Factor marginalizeOut(VarSet varset)

  Description copied from interface: `Factor`
  Returns the marginal distribution attained by summing out the given set of variables.

  Specified by:
    `marginalizeOut` in interface `Factor`

### extractMax

    public Factor extractMax(Variable[] vars)

  Description copied from interface: `Factor`
  Returns a potential phi over the given variables obtained by taking phi (x) = max_[all v that contain x] this.prob (x)

  Specified by:
    `extractMax` in interface `Factor`

### extractMax

    public Factor extractMax(java.util.Collection vars)

  Description copied from interface: `Factor`
  Returns a potential phi over the given variables obtained by taking phi (x) = max_[all v that contain x] this.prob (x)

  Specified by:
    `extractMax` in interface `Factor`

### extractMax

    public Factor extractMax(Variable var)

  Description copied from interface: `Factor`
  Returns a potential phi over the given variables obtained by taking phi (x) = max_[all v that contain x] this.prob (x)

  Specified by:
    `extractMax` in interface `Factor`

### argmax

    public int argmax()

  Description copied from interface: `Factor`
  Returns the assignment that maximizes this potential.

  Specified by:
    `argmax` in interface `Factor`

### sample

    public Assignment sample(Randoms r)

  Description copied from interface: `Factor`
  Return an assignment sampled from this factor, interpreting it as an unnormalized probability distribution.

  Specified by:
    `sample` in interface `Factor`

### sum

    public double sum()

  Description copied from interface: `Factor`
  Returns the sum of this potential over all cases.

  Specified by:
    `sum` in interface `Factor`

### entropy

    public double entropy()

  Description copied from interface: `Factor`
  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.

  Specified by:
    `entropy` in interface `Factor`

### multiply

    public Factor multiply(Factor dist)

  Description copied from interface: `Factor`
  Returns the elementwise product of this factor with another.

  Specified by:
    `multiply` in interface `Factor`

### multiplyBy

    public void multiplyBy(Factor pot)

  Description copied from interface: `Factor`
  Does this *= pot.

  If both potentials are currently in log space, then does addition instead.

  Specified by:
    `multiplyBy` in interface `Factor`

### exponentiate

    public void exponentiate(double power)

  Specified by:
    `exponentiate` in interface `Factor`

### divideBy

    public void divideBy(Factor pot)

  Description copied from interface: `Factor`
  Computes this /= pot

  If both potentials are currently in log space, then does subtraction instead.

  Specified by:
    `divideBy` in interface `Factor`

### isInLogSpace

    public boolean isInLogSpace()

### logify

    public void logify()

### delogify

    public void delogify()

### log

    public Factor log()

### containsVar

    public boolean containsVar(Variable var)

  Description copied from interface: `Factor`
  Returns whether the potential is over the given variable.

  Specified by:
    `containsVar` in interface `Factor`

### varSet

    public VarSet varSet()

  Description copied from interface: `Factor`
  Returns set of variables in this potential.

  Specified by:
    `varSet` in interface `Factor`

### assignmentIterator

    public AssignmentIterator assignmentIterator()

  Description copied from interface: `Factor`
  Returns an iterator over all Assignmentss to this potential.

  Specified by:
    `assignmentIterator` in interface `Factor`

### almostEquals

    public boolean almostEquals(Factor p)

  Description copied from interface: `Factor`
  Returns whether this is almost equal to another potential.

  Specified by:
    `almostEquals` in interface `Factor`

### logValue

    public double logValue(Assignment assn)

  Specified by:
    `logValue` in interface `Factor`

### logValue

    public double logValue(AssignmentIterator it)

  Specified by:
    `logValue` in interface `Factor`

### logValue

    public double logValue(int loc)

  Specified by:
    `logValue` in interface `Factor`

### getVariable

    public Variable getVariable(int i)

  Specified by:
    `getVariable` in interface `Factor`

### asTable

    public AbstractTableFactor asTable()

  Specified by:
    `asTable` in interface `Factor`

### setVarSet

    protected void setVarSet(VarSet vars)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD