wolffd@0: wolffd@0: wolffd@0: wolffd@0: Netlab Reference Manual metrop wolffd@0: wolffd@0: wolffd@0: wolffd@0:

metrop wolffd@0:

wolffd@0:

wolffd@0: Purpose wolffd@0:

wolffd@0: Markov Chain Monte Carlo sampling with Metropolis algorithm. wolffd@0: wolffd@0:

wolffd@0: Synopsis wolffd@0:

wolffd@0:
wolffd@0: 
wolffd@0: samples = metrop(f, x, options)
wolffd@0: samples = metrop(f, x, options, [], P1, P2, ...)
wolffd@0: [samples, energies, diagn] = metrop(f, x, options)
wolffd@0: s = metrop('state')
wolffd@0: metrop('state', s)
wolffd@0: 
wolffd@0: wolffd@0: wolffd@0:

wolffd@0: Description wolffd@0:

wolffd@0: wolffd@0: samples = metrop(f, x, options) uses wolffd@0: the Metropolis algorithm to sample from the distribution wolffd@0: p ~ exp(-f), where f is the first argument to metrop. wolffd@0: The Markov chain starts at the point x and each wolffd@0: candidate state is picked from a Gaussian proposal distribution and wolffd@0: accepted or rejected according to the Metropolis criterion. wolffd@0: wolffd@0:

samples = metrop(f, x, options, [], p1, p2, ...) allows wolffd@0: additional arguments to be passed to f(). The fourth argument is wolffd@0: ignored, but is included for compatibility with hmc and the wolffd@0: optimisers. wolffd@0: wolffd@0:

[samples, energies, diagn] = metrop(f, x, options) also returns wolffd@0: a log of the energy values (i.e. negative log probabilities) for the wolffd@0: samples in energies and diagn, a structure containing wolffd@0: diagnostic information (position and wolffd@0: acceptance threshold) for each step of the chain in diagn.pos and wolffd@0: diagn.acc respectively. All candidate states (including rejected wolffd@0: ones) are stored in diagn.pos. wolffd@0: wolffd@0:

s = metrop('state') returns a state structure that contains the wolffd@0: state of the two random number generators rand and randn. wolffd@0: These are contained in fields wolffd@0: randstate, wolffd@0: randnstate. wolffd@0: wolffd@0:

metrop('state', s) resets the state to s. If s is an integer, wolffd@0: then it is passed to rand and randn. wolffd@0: If s is a structure returned by metrop('state') then wolffd@0: it resets the generator to exactly the same state. wolffd@0: wolffd@0:

The optional parameters in the options vector have the following wolffd@0: interpretations. wolffd@0: wolffd@0:

options(1) is set to 1 to display the energy values and rejection wolffd@0: threshold at each step of the Markov chain. If the value is 2, then the wolffd@0: position vectors at each step are also displayed. wolffd@0: wolffd@0:

options(14) is the number of samples retained from the Markov chain; wolffd@0: default 100. wolffd@0: wolffd@0:

options(15) is the number of samples omitted from the start of the wolffd@0: chain; default 0. wolffd@0: wolffd@0:

options(18) is the variance of the proposal distribution; default 1. wolffd@0: wolffd@0:

wolffd@0: Examples wolffd@0:

wolffd@0: The following code fragment samples from the posterior distribution of wolffd@0: weights for a neural network. wolffd@0:
wolffd@0: 
wolffd@0: w = mlppak(net);
wolffd@0: [samples, energies] = metrop('neterr', w, options, 'netgrad', net, x, t);
wolffd@0: 
wolffd@0: wolffd@0: wolffd@0:

wolffd@0: Algorithm wolffd@0:

wolffd@0: wolffd@0: The algorithm follows the procedure outlined in Radford Neal's technical wolffd@0: report CRG-TR-93-1 from the University of Toronto. wolffd@0: wolffd@0:

wolffd@0: See Also wolffd@0:

wolffd@0: hmc
wolffd@0: Pages: wolffd@0: Index wolffd@0:
wolffd@0:

Copyright (c) Ian T Nabney (1996-9) wolffd@0: wolffd@0: wolffd@0: wolffd@0: