gov.sandia.cognition.statistics.bayesian
Class RejectionSampling<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.RejectionSampling<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="Rejection Sampling",
                      type=WebPage,
                      year=2009,
                      url="http://en.wikipedia.org/wiki/Rejection_sampling")
public class RejectionSampling<ObservationType,ParameterType>
extends AbstractRandomized
implements BayesianEstimator<ObservationType,ParameterType,DataDistribution<ParameterType>>

Rejection sampling is a method of inferring hidden parameters by using an easy-to-sample-from distribution (times a scale factor) that envelopes another distribution that is difficult to sample from. Typically, we sample from the parameter prior to infer the likelihood of the parameters given an observation sequence. In my limited experience, vanilla rejection sampling, implemented here, is inferior to ImportanceSamping.

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

Nested Class Summary
static class RejectionSampling.DefaultUpdater<ObservationType,ParameterType>
          Default ImportanceSampling Updater that uses a BayesianParameter to compute the quantities of interest.
static class RejectionSampling.ScalarEstimator<ObservationType>
          Routine for estimating the minimum scalar needed to envelop the conjunctive distribution.
static interface RejectionSampling.Updater<ObservationType,ParameterType>
          Updater for ImportanceSampling
 
Field Summary
static int DEFAULT_NUM_SAMPLES
          Default number of samples, 1000.
protected  RejectionSampling.Updater<ObservationType,ParameterType> updater
          Updater for the ImportanceSampling algorithm.
 
Fields inherited from class gov.sandia.cognition.util.AbstractRandomized
random
 
Constructor Summary
RejectionSampling()
          Creates a new instance of RejectionSampling
 
Method Summary
 RejectionSampling<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
 RejectionSampling.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(RejectionSampling.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 number of samples, 1000.

See Also:
Constant Field Values

updater

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

Constructor Detail

RejectionSampling

public RejectionSampling()
Creates a new instance of RejectionSampling

Method Detail

clone

public RejectionSampling<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.

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.

getUpdater

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

Returns:
Updater for the ImportanceSampling algorithm.

setUpdater

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

Parameters:
updater - Updater for the ImportanceSampling algorithm.