ObservationType
- Type of observations handled by the MCMC algorithm.ParameterType
- Type of parameters to infer.@PublicationReference(author="Wikipedia", title="Metropolis\u2013Hastings algorithm", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Metropolis-Hastings_algorithm") public class MetropolisHastingsAlgorithm<ObservationType,ParameterType> extends AbstractMarkovChainMonteCarlo<ObservationType,ParameterType> implements MeasurablePerformanceAlgorithm
Modifier and Type | Class and Description |
---|---|
static interface |
MetropolisHastingsAlgorithm.Updater<ObservationType,ParameterType>
Creates proposals for the MCMC steps.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PERFORMANCE_NAME
Performance statistic name, "Current Log Likelihood".
|
protected MetropolisHastingsAlgorithm.Updater<ObservationType,ParameterType> |
updater
The object that makes proposal samples from the current location.
|
currentParameter, DEFAULT_NUM_SAMPLES, previousParameter, random
data, keepGoing
maxIterations
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
MetropolisHastingsAlgorithm()
Creates a new instance of MetropolisHastingsAlgorithm.
|
Modifier and Type | Method and Description |
---|---|
MetropolisHastingsAlgorithm<ObservationType,ParameterType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
ParameterType |
createInitialLearnedObject()
Creates the initial parameters from which to start the Markov chain.
|
NamedValue<java.lang.Double> |
getPerformance()
Gets the name-value pair that describes the current performance of the
algorithm.
|
MetropolisHastingsAlgorithm.Updater<ObservationType,ParameterType> |
getUpdater()
Gets the object that makes proposal samples from the current location.
|
protected boolean |
initializeAlgorithm()
Called to initialize the learning algorithm's state based on the
data that is stored in the data field.
|
protected void |
mcmcUpdate()
Performs a valid MCMC update step.
|
void |
setUpdater(MetropolisHastingsAlgorithm.Updater<ObservationType,ParameterType> updater)
Sets the object that makes proposal samples from the current location.
|
cleanupAlgorithm, getBurnInIterations, getCurrentParameter, getIterationsPerSample, getPreviousParameter, getRandom, getResult, setBurnInIterations, setCurrentParameter, setIterationsPerSample, setRandom, setResult, step
getData, getKeepGoing, learn, setData, setKeepGoing, stop
getMaxIterations, isResultValid, setMaxIterations
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
learn
getMaxIterations, setMaxIterations
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
isResultValid, stop
public static final java.lang.String PERFORMANCE_NAME
protected MetropolisHastingsAlgorithm.Updater<ObservationType,ParameterType> updater
public MetropolisHastingsAlgorithm()
public MetropolisHastingsAlgorithm<ObservationType,ParameterType> clone()
AbstractCloneableSerializable
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.clone
in interface CloneableSerializable
clone
in class AbstractMarkovChainMonteCarlo<ObservationType,ParameterType>
protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearner
initializeAlgorithm
in class AbstractMarkovChainMonteCarlo<ObservationType,ParameterType>
protected void mcmcUpdate()
AbstractMarkovChainMonteCarlo
mcmcUpdate
in class AbstractMarkovChainMonteCarlo<ObservationType,ParameterType>
public NamedValue<java.lang.Double> getPerformance()
MeasurablePerformanceAlgorithm
getPerformance
in interface MeasurablePerformanceAlgorithm
public MetropolisHastingsAlgorithm.Updater<ObservationType,ParameterType> getUpdater()
public void setUpdater(MetropolisHastingsAlgorithm.Updater<ObservationType,ParameterType> updater)
updater
- The object that makes proposal samples from the current location.public ParameterType createInitialLearnedObject()
AbstractMarkovChainMonteCarlo
createInitialLearnedObject
in class AbstractMarkovChainMonteCarlo<ObservationType,ParameterType>