wolffd@0: wolffd@0: wolffd@0: wolffd@0: Netlab Reference Manual hmc wolffd@0: wolffd@0: wolffd@0: wolffd@0:

hmc wolffd@0:

wolffd@0:

wolffd@0: Purpose wolffd@0:

wolffd@0: Hybrid Monte Carlo sampling. wolffd@0: wolffd@0:

wolffd@0: Synopsis wolffd@0:

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

wolffd@0: Description wolffd@0:

wolffd@0: samples = hmc(f, x, options, gradf) uses a wolffd@0: hybrid Monte Carlo algorithm to sample from the distribution p ~ exp(-f), wolffd@0: where f is the first argument to hmc. wolffd@0: The Markov chain starts at the point x, and the function gradf wolffd@0: is the gradient of the `energy' function f. wolffd@0: wolffd@0:

hmc(f, x, options, gradf, p1, p2, ...) allows wolffd@0: additional arguments to be passed to f() and gradf(). wolffd@0: wolffd@0:

[samples, energies, diagn] = hmc(f, x, options, gradf) 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, momentum and wolffd@0: acceptance threshold) for each step of the chain in diagn.pos, wolffd@0: diagn.mom and wolffd@0: diagn.acc respectively. All candidate states (including rejected ones) wolffd@0: are stored in diagn.pos. wolffd@0: wolffd@0:

[samples, energies, diagn] = hmc(f, x, options, gradf) also returns the wolffd@0: energies (i.e. negative log probabilities) corresponding to the samples. wolffd@0: The diagn structure contains three fields: wolffd@0: wolffd@0:

pos the position vectors of the dynamic process. wolffd@0: wolffd@0:

mom the momentum vectors of the dynamic process. wolffd@0: wolffd@0:

acc the acceptance thresholds. wolffd@0: wolffd@0:

s = hmc('state') returns a state structure that contains the state of the wolffd@0: two random number generators rand and randn and the momentum of wolffd@0: the dynamic process. These are contained in fields wolffd@0: randstate, randnstate wolffd@0: and mom respectively. The momentum state is wolffd@0: only used for a persistent momentum update. wolffd@0: wolffd@0:

hmc('state', s) resets the state to s. If s is an integer, wolffd@0: then it is passed to rand and randn and the momentum variable wolffd@0: is randomised. If s is a structure returned by hmc('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(5) is set to 1 if momentum persistence is used; default 0, for wolffd@0: complete replacement of momentum variables. wolffd@0: wolffd@0:

options(7) defines the trajectory length (i.e. the number of leap-frog wolffd@0: steps at each iteration). Minimum value 1. wolffd@0: wolffd@0:

options(9) is set to 1 to check the user defined gradient function. 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(17) defines the momentum used when a persistent update of wolffd@0: (leap-frog) momentum is used. This is bounded to the interval [0, 1). wolffd@0: wolffd@0:

options(18) is the step size used in leap-frogs; default 1/trajectory wolffd@0: length. 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] = hmc('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 algroithm follows the procedure outlined in Radford Neal's technical wolffd@0: report CRG-TR-93-1 from the University of Toronto. The stochastic update of wolffd@0: momenta samples from a zero mean unit covariance gaussian. wolffd@0: wolffd@0:

wolffd@0: See Also wolffd@0:

wolffd@0: metrop
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: