gov.sandia.cognition.statistics.montecarlo
Class ImportanceSampler<DataType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.statistics.montecarlo.ImportanceSampler<DataType>
Type Parameters:
DataType - Type of Data sampled.
All Implemented Interfaces:
MonteCarloSampler<DataType,WeightedValue<DataType>,Evaluator<? super DataType,Double>>, CloneableSerializable, Serializable, Cloneable

@PublicationReference(author="Wikipedia",
                      title="Importance Sampling",
                      type=WebPage,
                      year=2009,
                      url="http://en.wikipedia.org/wiki/Importance_sampling")
public class ImportanceSampler<DataType>
extends AbstractCloneableSerializable
implements MonteCarloSampler<DataType,WeightedValue<DataType>,Evaluator<? super DataType,Double>>

Importance sampling is a technique for estimating properties of a target distribution, while only having samples generated from an "importance" distribution rather than the target distribution. Typically, the importance distribution is easy to sample from, while the target distribution is difficult to sample from, and the importance distribution has support everywhere that the target distribution has support. Then, this results in an weighted set of samples that are an unbiased sampling of the target distribution.

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

Constructor Summary
ImportanceSampler()
          Creates a new instance of ImportanceSampler
ImportanceSampler(ProbabilityDensityFunction<DataType> importanceDistribution)
          Creates a new instance of ImportanceSampler.
 
Method Summary
 ImportanceSampler<DataType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 ProbabilityFunction<DataType> getImportanceDistribution()
          Getter for importanceDistribution.
 ArrayList<DefaultWeightedValue<DataType>> sample(Evaluator<? super DataType,Double> targetFunction, Random random, int numSamples)
          Draws samples according to the distribution of the target function.
 void setImportanceDistribution(ProbabilityFunction<DataType> importanceDistribution)
          Setter for importanceDistribution.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImportanceSampler

public ImportanceSampler()
Creates a new instance of ImportanceSampler


ImportanceSampler

public ImportanceSampler(ProbabilityDensityFunction<DataType> importanceDistribution)
Creates a new instance of ImportanceSampler.

Parameters:
importanceDistribution - Importance distribution from which we sample and weight by the target distribution.
Method Detail

clone

public ImportanceSampler<DataType> 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 AbstractCloneableSerializable
Returns:
A clone of this object.

sample

public ArrayList<DefaultWeightedValue<DataType>> sample(Evaluator<? super DataType,Double> targetFunction,
                                                        Random random,
                                                        int numSamples)
Description copied from interface: MonteCarloSampler
Draws samples according to the distribution of the target function.

Specified by:
sample in interface MonteCarloSampler<DataType,WeightedValue<DataType>,Evaluator<? super DataType,Double>>
Parameters:
targetFunction - Target function that we want to generate samples.
random - Random-number generator.
numSamples - Number of samples to generate.
Returns:
Samples

getImportanceDistribution

public ProbabilityFunction<DataType> getImportanceDistribution()
Getter for importanceDistribution.

Returns:
Importance distribution from which we sample and weight by the target distribution.

setImportanceDistribution

public void setImportanceDistribution(ProbabilityFunction<DataType> importanceDistribution)
Setter for importanceDistribution.

Parameters:
importanceDistribution - Importance distribution from which we sample and weight by the target distribution.