Class RobustAdaptiveMetropolis

  • All Implemented Interfaces:
    RandomVectorGenerator, Seedable

    public class RobustAdaptiveMetropolis
    extends AbstractMetropolis
    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:
    • Vihola, M. "Robust adaptive Metropolis algorithm with coerced acceptance rate," Statistics and Computing. 2011.
    • R package: adaptMCMC
    • Constructor Detail

      • 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 sample
        initialScale - 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 rate
        initialState - the initial state of the algorithm
        rnorm - the random standard Normal generator to be used
        uniform - 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 sample
        targetAcceptance - the target acceptance rate
        initialState - the initial state of the algorithm
        uniform - the random long generator to be used
    • Method Detail

      • isProposalAccepted

        protected boolean isProposalAccepted​(Vector currentState,
                                             Vector proposedState)
        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 class AbstractMetropolis
        Parameters:
        currentState - the current state of the system
        proposedState - the proposed next state of the system
        Returns:
        whether the system should accept the proposed next state
      • S

        public Matrix S()
        Gets the tuned scaling matrix (this changes each time a new sample is drawn).
        Returns:
        the scaling matrix