blog
Class GenericProposer

java.lang.Object
  extended by blog.GenericProposer
All Implemented Interfaces:
Proposer
Direct Known Subclasses:
DecayedProposer

public class GenericProposer
extends java.lang.Object
implements Proposer

Implements a generic MCMC proposal algorithm. Each step changes the value of exactly one instantiated RV (selected uniformly at random from the instantiated RVs), then samples values for previously uninstantiated RVs to make the resulting instantiation self-supporting. It also uninstantiates any RVs that become barren.

Each variable is sampled from its prior distribution given its parents. The forward proposal probability is just the probability of choosing the selected variable to change, times the product of the probabilities of values sampled (for that variable and any other variables that must be instantiated to make the instantiation self-supporting). The backward probability is the probability of choosing the same variable again, choosing its old value, and re-instantiating all the newly uninstantiated variables to their old values. No other moves can yield the same proposed world because each move changes the value of exactly one instantiated variable (it just instantiates and uninstantiates other variables).

GenericProposer does not use identifiers in the worlds it constructs.


Nested Class Summary
protected  class GenericProposer.PickVarToSampleResult
           
 
Field Summary
protected  Evidence evidence
           
protected  java.util.Set evidenceVars
           
protected  Sampler initialStateSampler
           
protected  double logProbBackward
           
protected  double logProbForward
           
protected  Model model
           
protected  int numBasicEvidenceVars
           
protected  int numInitialStateTriesThisTrial
           
protected  int numTrials
           
protected  java.util.List queries
           
protected  java.util.Set queryVars
           
protected  int totalNumInitialStateTries
           
 
Constructor Summary
GenericProposer(Model model, java.util.Properties properties)
          Creates a new GenericProposer that proposes possible worlds for the given model.
 
Method Summary
 void add(Evidence evidence)
          Adds extra evidence to the evidence the proposer must consider.
 void addQueries(java.util.List queries)
          Adds extra queries to the ones the proposer must consider.
protected  PartialWorldDiff constructInitialState()
          Actually builds initial state, after whatever initializations are necessary.
 PartialWorldDiff initialize(Evidence evidence, java.util.List queries)
          Set up the initial state.
protected  GenericProposer.PickVarToSampleResult pickVarToSample(PartialWorld world)
           
 void printStats()
          Prints any relevant statistics about the internal behavior of this proposer.
 double proposeNextState(PartialWorldDiff world)
          Proposes a next state for the Markov chain given the current state.
 void updateStats(boolean accepted)
          Updates any statistics maintained by this proposer to reflect the fact that the most recent proposal was accepted (if accepted is true) or rejected (if accepted is false).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected Model model

initialStateSampler

protected Sampler initialStateSampler

evidence

protected Evidence evidence

queries

protected java.util.List queries

evidenceVars

protected java.util.Set evidenceVars

numBasicEvidenceVars

protected int numBasicEvidenceVars

queryVars

protected java.util.Set queryVars

logProbForward

protected double logProbForward

logProbBackward

protected double logProbBackward

numTrials

protected int numTrials

totalNumInitialStateTries

protected int totalNumInitialStateTries

numInitialStateTriesThisTrial

protected int numInitialStateTriesThisTrial
Constructor Detail

GenericProposer

public GenericProposer(Model model,
                       java.util.Properties properties)
Creates a new GenericProposer that proposes possible worlds for the given model. The properties table, specifying configuration parameters, is passed to the LWSampler that is used to generate the initial world.

Method Detail

initialize

public PartialWorldDiff initialize(Evidence evidence,
                                   java.util.List queries)
Set up the initial state. We repeatedly sample a world until we get one where the observed values of the evidence variables have positive probability.

Specified by:
initialize in interface Proposer
queries - List of Query objects

add

public void add(Evidence evidence)
Adds extra evidence to the evidence the proposer must consider.


addQueries

public void addQueries(java.util.List queries)
Adds extra queries to the ones the proposer must consider.


constructInitialState

protected PartialWorldDiff constructInitialState()
Actually builds initial state, after whatever initializations are necessary. Separated from initialize(Evidence,List) so extensions can change it alone.


pickVarToSample

protected GenericProposer.PickVarToSampleResult pickVarToSample(PartialWorld world)

proposeNextState

public double proposeNextState(PartialWorldDiff world)
Proposes a next state for the Markov chain given the current state. The proposedWorld argument is a PartialWorldDiff that the proposer can modify to create the proposal; the saved version of this PartialWorldDiff is the state before the proposal. Returns the log proposal ratio: log (q(x | x') / q(x' | x))

Specified by:
proposeNextState in interface Proposer

printStats

public void printStats()
Description copied from interface: Proposer
Prints any relevant statistics about the internal behavior of this proposer.

Specified by:
printStats in interface Proposer

updateStats

public void updateStats(boolean accepted)
Description copied from interface: Proposer
Updates any statistics maintained by this proposer to reflect the fact that the most recent proposal was accepted (if accepted is true) or rejected (if accepted is false).

Specified by:
updateStats in interface Proposer