Daniel@0: Daniel@0: Daniel@0: Daniel@0: Netlab Reference Manual metrop Daniel@0: Daniel@0: Daniel@0: Daniel@0:

metrop Daniel@0:

Daniel@0:

Daniel@0: Purpose Daniel@0:

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

Daniel@0: Synopsis Daniel@0:

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

Daniel@0: Description Daniel@0:

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

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

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

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

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

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

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

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

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

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

Daniel@0: Examples Daniel@0:

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

Daniel@0: Algorithm Daniel@0:

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

Daniel@0: See Also Daniel@0:

Daniel@0: hmc
Daniel@0: Pages: Daniel@0: Index Daniel@0:
Daniel@0:

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