public class Metropolis extends AbstractMetropolis
Constructor and Description |
---|
Metropolis(RealScalarFunction logf,
RealVectorFunction proposalFunction,
Vector initialState,
RandomLongGenerator uniform)
Constructs a new instance with the given parameters.
|
Metropolis(RealScalarFunction logf,
Vector initialState,
double sigma,
RandomLongGenerator uniform)
Constructs a new instance, which draws the offset of the next proposed state from the
previous state from a standard Normal distribution, with the given variance and zero
covariance.
|
Metropolis(RealScalarFunction logf,
Vector initialState,
Matrix scale,
RandomLongGenerator uniform)
Constructs a new instance, which draws the offset of the next proposed state from the
previous state from a standard Normal distribution, multiplied by the given scale matrix.
|
Modifier and Type | Method and Description |
---|---|
protected 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.
|
acceptanceRate, nextVector, seed
public Metropolis(RealScalarFunction logf, RealVectorFunction proposalFunction, Vector initialState, RandomLongGenerator uniform)
logf
- the log of the unnormalized pdf from which we wish to sampleproposalFunction
- generates a proposal for the next state, given the current state.
This function MUST be symmetric about it's input argument for the algorithm to
converge.initialState
- the initial state of the algorithmuniform
- the random long generator to be used. This should be the same RLG
that is used in the proposal function.public Metropolis(RealScalarFunction logf, Vector initialState, double sigma, RandomLongGenerator uniform)
logf
- the log of the unnormalized pdf from which we wish to sampleinitialState
- the initial state of the algorithmsigma
- the standard deviation the Normal random vector generated by the proposal
distributionuniform
- the random long generator to be used. This should be the same RLG
that is used in the proposal function.public Metropolis(RealScalarFunction logf, Vector initialState, Matrix scale, RandomLongGenerator uniform)
logf
- the log of the unnormalized pdf from which we wish to sampleinitialState
- the initial state of the algorithmscale
- the square root of the covariance matrix, where the next proposal is
computed by x+scale*z, where x is the previous proposal and z is a standard Normal random
vectoruniform
- the random long generator to be used. This should be the same RLG
that is used in the proposal function.protected Vector nextProposedState(Vector currentState)
AbstractMetropolis
nextProposedState
in class AbstractMetropolis
currentState
- the current state of the systemprotected boolean isProposalAccepted(Vector currentState, Vector proposedState)
AbstractMetropolis
isProposalAccepted
in class AbstractMetropolis
currentState
- the current state of the systemproposedState
- the proposed next state of the systemCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.