Class RobustAdaptiveMetropolis
java.lang.Object
dev.nm.stat.random.rng.multivariate.mcmc.metropolis.AbstractMetropolis
dev.nm.stat.random.rng.multivariate.mcmc.metropolis.RobustAdaptiveMetropolis
- All Implemented Interfaces:
RandomVectorGenerator
,Seedable
A variation of Metropolis, that uses the estimated covariance of the target
distribution in the proposal distribution, based on a paper by Vihola (2011).
The algorithm adjusts it's approximation of the variance/covariance after each sample has been
drawn, according to a decaying step size, in order to match the given target acceptance rate.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRobustAdaptiveMetropolis
(RealScalarFunction logf, double targetAcceptance, Vector initialState, RandomLongGenerator uniform) Constructs an instance which assumes an initial variance of 1 per variable, uses a gamma of 0.5.RobustAdaptiveMetropolis
(RealScalarFunction logf, Matrix initialScale, double gamma, double targetAcceptance, Vector initialState, RandomStandardNormalGenerator rnorm, RandomLongGenerator uniform) Constructs a new instance with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
isProposalAccepted
(Vector currentState, Vector proposedState) Decides whether the given proposed state should be accepted, or whether the system should remain in it's current state.protected Vector
nextProposedState
(Vector currentState) Proposes a next state for the system.S()
Gets the tuned scaling matrix (this changes each time a new sample is drawn).Methods inherited from class dev.nm.stat.random.rng.multivariate.mcmc.metropolis.AbstractMetropolis
acceptanceRate, nextVector, seed
-
Constructor Details
-
RobustAdaptiveMetropolis
public RobustAdaptiveMetropolis(RealScalarFunction logf, Matrix initialScale, double gamma, double targetAcceptance, Vector initialState, RandomStandardNormalGenerator rnorm, RandomLongGenerator uniform) Constructs a new instance with the given parameters.- Parameters:
logf
- the log of the unnormalized pdf from which we wish to sampleinitialScale
- the initial scale matrix, the square root of the covariance matrix, applied to the vector of independently distributed Normal variables. This must be a lower triangular matrix with positive diagonal elements.gamma
- a value between 0.5 and 1, that controls the speed of adaption. A lower gamma will lead to faster adoption.targetAcceptance
- the target acceptance rateinitialState
- the initial state of the algorithmrnorm
- the random standard Normal generator to be useduniform
- the random long generator to be used
-
RobustAdaptiveMetropolis
public RobustAdaptiveMetropolis(RealScalarFunction logf, double targetAcceptance, Vector initialState, RandomLongGenerator uniform) Constructs an instance which assumes an initial variance of 1 per variable, uses a gamma of 0.5. These parameters are suitable for many applications, though it may achieve better performance (faster execution and/or better mixing), by tweaking them.- Parameters:
logf
- the log of the unnormalized pdf from which we wish to sampletargetAcceptance
- the target acceptance rateinitialState
- the initial state of the algorithmuniform
- the random long generator to be used
-
-
Method Details
-
nextProposedState
Description copied from class:AbstractMetropolis
Proposes a next state for the system.- Specified by:
nextProposedState
in classAbstractMetropolis
- Parameters:
currentState
- the current state of the system- Returns:
- the proposed next state
-
isProposalAccepted
Description copied from class:AbstractMetropolis
Decides whether the given proposed state should be accepted, or whether the system should remain in it's current state.- Specified by:
isProposalAccepted
in classAbstractMetropolis
- Parameters:
currentState
- the current state of the systemproposedState
- the proposed next state of the system- Returns:
- whether the system should accept the proposed next state
-
S
Gets the tuned scaling matrix (this changes each time a new sample is drawn).- Returns:
- the scaling matrix
-