Header menu logo bristlecone

MonteCarlo Module

A module containing Monte Carlo Markov Chain (MCMC) methods for optimisation. An introduction to MCMC approaches is provided by [Reali, Priami, and Marchetti (2017)](https://doi.org/10.3389/fams.2017.00006)

Types and nested modules

Type/Module Description

Filzbach

An adaptation of the Filzbach method (originally by Drew Purves)

MetropolisWithinGibbs

RandomWalk

SimulatedAnnealing

A meta-heuristic that approximates a global optimium by simulating slow cooling as a slow decrease in the probability of temporarily accepting worse solutions.

TuningMode

Frequency

TuneMethod

Functions and values

Function or value Description

``Adaptive-Metropolis-withinGibbs``

Full Usage: ``Adaptive-Metropolis-withinGibbs``

Returns: Optimiser<float>

An adaptive Metropolis-within-Gibbs sampler that tunes the variance of each parameter according to the per-parameter acceptance rate. Reference: Bai Y (2009). “An Adaptive Directional Metropolis-within-Gibbs Algorithm.” Technical Report in Department of Statistics at the University of Toronto.

Returns: Optimiser<float>

``Automatic(AdaptiveDiagnostics)``

Full Usage: ``Automatic(AdaptiveDiagnostics)``

Returns: Optimiser<float>

Implementation similar to that proposed by Yang and Rosenthal: "Automatically Tuned General-Purpose MCMC via New Adaptive Diagnostics" Reference: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.70.7198&rep=rep1&type=pdf

Returns: Optimiser<float>

``Metropolis-withinGibbs``

Full Usage: ``Metropolis-withinGibbs``

Returns: Optimiser<float>

A non-adaptive Metropolis-within-gibbs Sampler. Each parameter is updated individually, unlike the random walk algorithm.

Returns: Optimiser<float>

adaptiveMetropolis weighting period

Full Usage: adaptiveMetropolis weighting period

Parameters:
Returns: Optimiser<float>

A Markov Chain Monte Carlo (MCMC) sampling algorithm that continually adjusts the covariance matrix based on the recently-sampled posterior distribution. Proposed jumps are therefore tuned to the recent history of accepted jumps.

weighting : float
period : Frequency
Returns: Optimiser<float>

constrainJump initial jump scaleFactor c

Full Usage: constrainJump initial jump scaleFactor c

Parameters:
    initial : float
    jump : float
    scaleFactor : float
    c : Constraint

Returns: float

Jump in parameter space while reflecting constraints.

initial : float
jump : float
scaleFactor : float
c : Constraint
Returns: float

metropolisHastings' random writeOut endCondition propose tune f theta1 l1 d scale iteration

Full Usage: metropolisHastings' random writeOut endCondition propose tune f theta1 l1 d scale iteration

Parameters:
    random : Random - `System.Random` to be used for drawing from a uniform distribution.
    writeOut : LogEvent -> unit - side-effect function for handling `LogEvent` items.
    endCondition : (float * float[]) list -> int -> bool - `EndCondition` that dictates when the MH algorithm ends.
    propose : 'a -> float[] -> float[] - proposal `'scale -> 'theta -> 'theta` that generates a jump based on the scale value.
    tune : int -> (float * float[]) list -> 'a -> 'a - parameter of type `int -> (float * 'a) list -> 'b -> 'b`, where `int` is current iteration,
    f : float[] -> float - an objective function, `'a -> float`, to optimise.
    theta1 : float[] - initial position in parameter space of type `'a`.
    l1 : float - initial value of -log likelihood at theta1 in parameter space
    d : (float * float[]) list - history of the chain, of type `(float * 'a) list`. Passing a list here allows continuation of a previous analysis.
    scale : 'a - a scale of type `'b`, which is compatible with the scale tuning function `tune`
    iteration : int - the current iteration number

Returns: (float * float[]) list * 'a `(float * 'a) list * 'b` - A tuple containing a list of results, and the final scale used in the analysis. The `(float * 'a) list` represents a list of paired -log likelihood values with the proposed theta.

A recursive metropolis hastings algorithm that ends when `endCondition` returns true.

random : Random

`System.Random` to be used for drawing from a uniform distribution.

writeOut : LogEvent -> unit

side-effect function for handling `LogEvent` items.

endCondition : (float * float[]) list -> int -> bool

`EndCondition` that dictates when the MH algorithm ends.

propose : 'a -> float[] -> float[]

proposal `'scale -> 'theta -> 'theta` that generates a jump based on the scale value.

tune : int -> (float * float[]) list -> 'a -> 'a

parameter of type `int -> (float * 'a) list -> 'b -> 'b`, where `int` is current iteration,

f : float[] -> float

an objective function, `'a -> float`, to optimise.

theta1 : float[]

initial position in parameter space of type `'a`.

l1 : float

initial value of -log likelihood at theta1 in parameter space

d : (float * float[]) list

history of the chain, of type `(float * 'a) list`. Passing a list here allows continuation of a previous analysis.

scale : 'a

a scale of type `'b`, which is compatible with the scale tuning function `tune`

iteration : int

the current iteration number

Returns: (float * float[]) list * 'a

`(float * 'a) list * 'b` - A tuple containing a list of results, and the final scale used in the analysis. The `(float * 'a) list` represents a list of paired -log likelihood values with the proposed theta.

randomWalk tuningSteps

Full Usage: randomWalk tuningSteps

Parameters:
Returns: Optimiser<float>

A Markov Chain Monte Carlo (MCMC) sampling algorithm that randomly 'walks' through a n-dimensional posterior distribution of the parameter space. Specify `tuningSteps` to prime the jump size before random walk.

tuningSteps : TuneStep<float> seq
Returns: Optimiser<float>

randomWalk' tuningSteps random writeOut n domain startPoint f

Full Usage: randomWalk' tuningSteps random writeOut n domain startPoint f

Parameters:
Returns: Solution<float> list
tuningSteps : TuneStep<float> seq
random : Random
writeOut : WriteOut
n : EndCondition<float>
domain : Domain
startPoint : Point<float> option
f : float[] -> float
Returns: Solution<float> list

toFn method interval

Full Usage: toFn method interval

Parameters:
Returns: int -> (float * float[]) seq -> Matrix<float> * float -> Matrix<float> * float
method : TuneMethod
interval : int
Returns: int -> (float * float[]) seq -> Matrix<float> * float -> Matrix<float> * float

Type something to start searching.