cc.mallet.grmm.inference
Class RandomGraphs

java.lang.Object
  extended by cc.mallet.grmm.inference.RandomGraphs

public class RandomGraphs
extends java.lang.Object

Utility class for generating many useful kinds of random graphical models. Created: Mar 26, 2005

Version:
$Id: RandomGraphs.java,v 1.1 2007/10/22 21:37:49 mccallum Exp $
Author:
Nested Class Summary
static interface RandomGraphs.FactorGenerator
           
static class RandomGraphs.UniformFactorGenerator
           
 
Constructor Summary
RandomGraphs()
           
 
Method Summary
static void addRandomNodePotentials(java.util.Random r, FactorGraph mdl)
           
static UndirectedModel createGrid(RandomGraphs.FactorGenerator gener, int size)
           
static FactorGraph createGridWithObs(RandomGraphs.FactorGenerator gridGener, RandomGraphs.FactorGenerator obsGener, int size)
           
static FactorGraph createRandomChain(Randoms r, int length)
           
static FactorGraph createUniformChain(int length)
           
static FactorGraph createUniformGrid(int length)
           
static double[] generateAttractivePotentialValues(java.util.Random r, double edgeWeight)
           
static double[] generateMixedPotentialValues(java.util.Random r, double edgeWeight)
           
static UndirectedGrid randomAttractiveGrid(int size, double edgeWeight, java.util.Random r)
          Constructs a square grid of a given size with random attractive potentials.
static UndirectedGrid randomFrustratedGrid(int size, double edgeWeight, java.util.Random r)
          Constructs a square grid of a given size with random frustrated potentials.
static UndirectedModel randomFrustratedTree(int size, int maxChildren, double edgeWeight, java.util.Random r)
           
static TableFactor randomNodePotential(java.util.Random r, Variable var)
           
static UndirectedGrid randomRepulsiveGrid(int size, double edgeWeight, java.util.Random r)
          Constructs a square grid of a given size with random repulsive potentials.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomGraphs

public RandomGraphs()
Method Detail

generateAttractivePotentialValues

public static double[] generateAttractivePotentialValues(java.util.Random r,
                                                         double edgeWeight)

generateMixedPotentialValues

public static double[] generateMixedPotentialValues(java.util.Random r,
                                                    double edgeWeight)

randomAttractiveGrid

public static UndirectedGrid randomAttractiveGrid(int size,
                                                  double edgeWeight,
                                                  java.util.Random r)
Constructs a square grid of a given size with random attractive potentials. Graphs are generated as follows:

We use a spin (i.e., {-1, 1}) representation. For each edge st, a single edge weight w_st is generated uniformly in (0,d). Then exponential parameters for the BM representation are chosen by

   theta_st = 4 * w_st
   theta_s = 2 (\sum(t in N(s)) w_st)
 

Parameters:
size - The length on one edge of the grid.
edgeWeight - A positive number giving the maximum potential strength
r - Object for generating random numbers.
Returns:
A randomly-generated undirected model.

randomRepulsiveGrid

public static UndirectedGrid randomRepulsiveGrid(int size,
                                                 double edgeWeight,
                                                 java.util.Random r)
Constructs a square grid of a given size with random repulsive potentials. This means that if a node takes on a value, its neighbors are more likely to take opposite values. Graphs are generated as follows:

We use a spin (i.e., {-1, 1}) representation. For each edge st, a single edge weight w_st is generated uniformly in (0,d). Then exponential parameters for the BM representation are chosen by

   theta_st = 4 * w_st
   theta_s = 2 (\sum(t in N(s)) w_st)
 

Parameters:
size - The length on one edge of the grid.
edgeWeight - A positive number giving the maximum ansolute potential strength
r - Object for generating random numbers.
Returns:
A randomly-generated undirected model.

randomFrustratedGrid

public static UndirectedGrid randomFrustratedGrid(int size,
                                                  double edgeWeight,
                                                  java.util.Random r)
Constructs a square grid of a given size with random frustrated potentials. This means that some potentials will be attractive (want to make their neighbors more like them) and some will be repulsive (want to make their neighbors different). Graphs are generated as follows:

We use a spin (i.e., {-1, 1}) representation. For each edge st, a single edge weight w_st is generated uniformly in (0,d). Then exponential parameters for the BM representation are chosen by

   theta_st = 4 * w_st
   theta_s = 2 (\sum(t in N(s)) w_st)
 

Parameters:
size - The length on one edge of the grid.
edgeWeight - A positive number giving the maximum potential strength
r - Object for generating random numbers.
Returns:
A randomly-generated undirected model.

randomFrustratedTree

public static UndirectedModel randomFrustratedTree(int size,
                                                   int maxChildren,
                                                   double edgeWeight,
                                                   java.util.Random r)

addRandomNodePotentials

public static void addRandomNodePotentials(java.util.Random r,
                                           FactorGraph mdl)

randomNodePotential

public static TableFactor randomNodePotential(java.util.Random r,
                                              Variable var)

createUniformChain

public static FactorGraph createUniformChain(int length)

createUniformGrid

public static FactorGraph createUniformGrid(int length)

createRandomChain

public static FactorGraph createRandomChain(Randoms r,
                                            int length)

createGrid

public static UndirectedModel createGrid(RandomGraphs.FactorGenerator gener,
                                         int size)

createGridWithObs

public static FactorGraph createGridWithObs(RandomGraphs.FactorGenerator gridGener,
                                            RandomGraphs.FactorGenerator obsGener,
                                            int size)