blog
Class LWSampler

java.lang.Object
  extended by blog.Sampler
      extended by blog.LWSampler

public class LWSampler
extends Sampler

A likelihood weighting sampler. Instantiates the context-specifically active ancestors of the query and evidence variables. Rather than sampling the evidence variables, it just instantiates them to their observed values. The weight of a sample is the product of the probabilities of the evidence variables given their parents.

The LWSampler constructor looks at the following properties in the properties table that is passed in:

idTypes
Comma-separated list of names of types. Non-guaranteed objects of these types will be represented by interchangeable identifiers rather than by tuples. The value can also be "none", indicating that no objects should be represented by identifiers, or "all", indicating that all non-guaranteed objects should be represented by identifiers. Default: "none".


Field Summary
 
Fields inherited from class blog.Sampler
evidence, model, queries
 
Constructor Summary
LWSampler(Model model, java.util.Properties properties)
          Creates a new sampler that for the given BLOG model.
 
Method Summary
 double getLatestWeight()
          Returns the weight for the world generated by the most recent call to nextSample.
 PartialWorld getLatestWorld()
          Returns the world generated by the most recent call to nextSample.
 void initialize(Evidence evidence, java.util.List queries)
          Prepares this sampler to sample from the distribution conditioned on the given evidence, returning PartialWorld objects that are complete enough to answer the given queries.
 void nextSample()
          Generates the next partial world and computes its weight.
 void printStats()
          Print statistics gathered during sampling to standard out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LWSampler

public LWSampler(Model model,
                 java.util.Properties properties)
Creates a new sampler that for the given BLOG model. The properties table specifies configuration parameters.

Method Detail

initialize

public void initialize(Evidence evidence,
                       java.util.List queries)
Description copied from class: Sampler
Prepares this sampler to sample from the distribution conditioned on the given evidence, returning PartialWorld objects that are complete enough to answer the given queries. Also clears the internal state of this sampler so that the next sample generated will be independent of all previous ones.

The default implementation just sets the evidence and queries member variables.

Overrides:
initialize in class Sampler
queries - List of Query objects

nextSample

public void nextSample()
Generates the next partial world and computes its weight.

Specified by:
nextSample in class Sampler

getLatestWorld

public PartialWorld getLatestWorld()
Description copied from class: Sampler
Returns the world generated by the most recent call to nextSample. The returned PartialWorld object may be modified by the next call to nextSample.

Specified by:
getLatestWorld in class Sampler

getLatestWeight

public double getLatestWeight()
Description copied from class: Sampler
Returns the weight for the world generated by the most recent call to nextSample. The default implementation returns 1.0.

Overrides:
getLatestWeight in class Sampler

printStats

public void printStats()
Print statistics gathered during sampling to standard out. These figures are gathered during each call to sample(). This method should be called once at the end of each trial.

Overrides:
printStats in class Sampler