gov.sandia.cognition.statistics.bayesian
Class ImportanceSampling<ObservationType,ParameterType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.util.AbstractRandomized
          extended by gov.sandia.cognition.statistics.bayesian.ImportanceSampling<ObservationType,ParameterType>
Type Parameters:
ObservationType - Type of observation
ParameterType - Type of parameters to infer
All Implemented Interfaces:
BatchLearner<Collection<? extends ObservationType>,DataDistribution<ParameterType>>, BayesianEstimator<ObservationType,ParameterType,DataDistribution<ParameterType>>, CloneableSerializable, Randomized, Serializable, Cloneable

@PublicationReference(author="Wikipedia",
                      title="Importance Sampling",
                      type=WebPage,
                      year=2009,
                      url="http://en.wikipedia.org/wiki/Importance_sampling")
public class ImportanceSampling<ObservationType,ParameterType>
extends AbstractRandomized
implements BayesianEstimator<ObservationType,ParameterType,DataDistribution<ParameterType>>

Importance sampling is a Monte Carlo inference technique where we sample from an easy distribution over the hidden variables (parameters) and then weight the result by the ratio of the likelihood of the parameters given the evidence and the likelihood of generating the parameters. This is a simple alternative to MCMC that is computationally simple, but does not scale well to many data points or many dimensions.

Since:
3.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Nested Class Summary
static class ImportanceSampling.DefaultUpdater<ObservationType,ParameterType>
          Default ImportanceSampling Updater that uses a BayesianParameter to compute the quantities of interest.
static interface ImportanceSampling.Updater<ObservationType,ParameterType>
          Updater for ImportanceSampling
 
Field Summary
static int DEFAULT_NUM_SAMPLES
          Default maximum number of samples, 1000.
protected  ImportanceSampling.Updater<ObservationType,ParameterType> updater
          Updater for the ImportanceSampling algorithm.
 
Fields inherited from class gov.sandia.cognition.util.AbstractRandomized
random
 
Constructor Summary
ImportanceSampling()
          Creates a new instance of ImportanceSampling
 
Method Summary
 ImportanceSampling<ObservationType,ParameterType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 int getNumSamples()
          Getter for numSamples
 ImportanceSampling.Updater<ObservationType,ParameterType> getUpdater()
          Getter for updater
 DataDistribution<ParameterType> learn(Collection<? extends ObservationType> data)
          The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.
 void setNumSamples(int numSamples)
          Setter for numSamples
 void setUpdater(ImportanceSampling.Updater<ObservationType,ParameterType> updater)
          Setter for updater
 
Methods inherited from class gov.sandia.cognition.util.AbstractRandomized
getRandom, setRandom
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NUM_SAMPLES

public static final int DEFAULT_NUM_SAMPLES
Default maximum number of samples, 1000.

See Also:
Constant Field Values

updater

protected ImportanceSampling.Updater<ObservationType,ParameterType> updater
Updater for the ImportanceSampling algorithm.

Constructor Detail

ImportanceSampling

public ImportanceSampling()
Creates a new instance of ImportanceSampling

Method Detail

clone

public ImportanceSampling<ObservationType,ParameterType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractRandomized
Returns:
A clone of this object.

learn

public DataDistribution<ParameterType> learn(Collection<? extends ObservationType> data)
Description copied from interface: BatchLearner
The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.

Specified by:
learn in interface BatchLearner<Collection<? extends ObservationType>,DataDistribution<ParameterType>>
Parameters:
data - The data that the learning algorithm will use to create an object of ResultType.
Returns:
The object that is created based on the given data using the learning algorithm.

getUpdater

public ImportanceSampling.Updater<ObservationType,ParameterType> getUpdater()
Getter for updater

Returns:
Updater for the ImportanceSampling algorithm.

setUpdater

public void setUpdater(ImportanceSampling.Updater<ObservationType,ParameterType> updater)
Setter for updater

Parameters:
updater - Updater for the ImportanceSampling algorithm.

getNumSamples

public int getNumSamples()
Getter for numSamples

Returns:
Number of samples.

setNumSamples

public void setNumSamples(int numSamples)
Setter for numSamples

Parameters:
numSamples - Number of samples.