cc.mallet.grmm.types
Class Factors

java.lang.Object
  extended by cc.mallet.grmm.types.Factors

public class Factors
extends java.lang.Object

A static utility class containing utility methods for dealing with factors, especially TableFactor objects. Created: Mar 17, 2005

Version:
$Id: Factors.java,v 1.1 2007/10/22 21:37:44 mccallum Exp $
Author:
Constructor Summary
Factors()
           
 
Method Summary
static Factor asFactor(Inferencer inf)
          Adapter that allows an Inferencer to be treated as if it were a factor.
static Factor average(Factor ptl1, Factor ptl2, double weight)
           
static int[] computeSizes(Factor result)
           
static Variable[] computeVars(Factor result)
           
static Variable[] continuousVarsOf(Factor fg)
           
static double corr(Factor factor)
           
static Variable[] discreteVarsOf(Factor fg)
           
static double distLinf(AbstractTableFactor f1, AbstractTableFactor f2)
           
static double distValueLinf(AbstractTableFactor f1, AbstractTableFactor f2)
           
static double euclideanDistance(AbstractTableFactor f1, AbstractTableFactor f2)
           
static double KL(AbstractTableFactor f1, AbstractTableFactor f2)
           
static double l1Distance(AbstractTableFactor f1, AbstractTableFactor f2)
           
static double logErrorRange(AbstractTableFactor f1, AbstractTableFactor f2)
          Implements the error range measure from Ihler et al.
static Factor mix(AbstractTableFactor f1, AbstractTableFactor f2, double alpha)
          Returns a new Factor F = alpha * f1 + (1 - alpha) * f2.
static Factor multiplyAll(java.util.Collection factors)
           
static double mutualInformation(Factor factor)
          Given a joint distribution over two variables, returns their mutual information.
static CPT normalizeAsCpt(AbstractTableFactor ptl, Variable var)
           
static double oneDistance(Factor bel1, Factor bel2)
           
static TableFactor retainMass(DiscreteFactor ptl, double alpha)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Factors

public Factors()
Method Detail

normalizeAsCpt

public static CPT normalizeAsCpt(AbstractTableFactor ptl,
                                 Variable var)

average

public static Factor average(Factor ptl1,
                             Factor ptl2,
                             double weight)

oneDistance

public static double oneDistance(Factor bel1,
                                 Factor bel2)

retainMass

public static TableFactor retainMass(DiscreteFactor ptl,
                                     double alpha)

computeSizes

public static int[] computeSizes(Factor result)

computeVars

public static Variable[] computeVars(Factor result)

mutualInformation

public static double mutualInformation(Factor factor)
Given a joint distribution over two variables, returns their mutual information.

Parameters:
factor - A joint distribution. Must be normalized, and over exactly two variables.
Returns:
The mutual inforamiton

KL

public static double KL(AbstractTableFactor f1,
                        AbstractTableFactor f2)

mix

public static Factor mix(AbstractTableFactor f1,
                         AbstractTableFactor f2,
                         double alpha)
Returns a new Factor F = alpha * f1 + (1 - alpha) * f2.


euclideanDistance

public static double euclideanDistance(AbstractTableFactor f1,
                                       AbstractTableFactor f2)

l1Distance

public static double l1Distance(AbstractTableFactor f1,
                                AbstractTableFactor f2)

asFactor

public static Factor asFactor(Inferencer inf)
Adapter that allows an Inferencer to be treated as if it were a factor.

Parameters:
inf - An inferencer on which computeMarginals() has been called.
Returns:
A factor

discreteVarsOf

public static Variable[] discreteVarsOf(Factor fg)

continuousVarsOf

public static Variable[] continuousVarsOf(Factor fg)

corr

public static double corr(Factor factor)

multiplyAll

public static Factor multiplyAll(java.util.Collection factors)

distLinf

public static double distLinf(AbstractTableFactor f1,
                              AbstractTableFactor f2)

distValueLinf

public static double distValueLinf(AbstractTableFactor f1,
                                   AbstractTableFactor f2)

logErrorRange

public static double logErrorRange(AbstractTableFactor f1,
                                   AbstractTableFactor f2)
Implements the error range measure from Ihler et al.