annotate toolboxes/FullBNT-1.0.7/nethelp3.3/metrop.htm @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 <html>
Daniel@0 2 <head>
Daniel@0 3 <title>
Daniel@0 4 Netlab Reference Manual metrop
Daniel@0 5 </title>
Daniel@0 6 </head>
Daniel@0 7 <body>
Daniel@0 8 <H1> metrop
Daniel@0 9 </H1>
Daniel@0 10 <h2>
Daniel@0 11 Purpose
Daniel@0 12 </h2>
Daniel@0 13 Markov Chain Monte Carlo sampling with Metropolis algorithm.
Daniel@0 14
Daniel@0 15 <p><h2>
Daniel@0 16 Synopsis
Daniel@0 17 </h2>
Daniel@0 18 <PRE>
Daniel@0 19
Daniel@0 20 samples = metrop(f, x, options)
Daniel@0 21 samples = metrop(f, x, options, [], P1, P2, ...)
Daniel@0 22 [samples, energies, diagn] = metrop(f, x, options)
Daniel@0 23 s = metrop('state')
Daniel@0 24 metrop('state', s)
Daniel@0 25 </PRE>
Daniel@0 26
Daniel@0 27
Daniel@0 28 <p><h2>
Daniel@0 29 Description
Daniel@0 30 </h2>
Daniel@0 31
Daniel@0 32 <CODE>samples = metrop(f, x, options)</CODE> uses
Daniel@0 33 the Metropolis algorithm to sample from the distribution
Daniel@0 34 <CODE>p ~ exp(-f)</CODE>, where <CODE>f</CODE> is the first argument to <CODE>metrop</CODE>.
Daniel@0 35 The Markov chain starts at the point <CODE>x</CODE> and each
Daniel@0 36 candidate state is picked from a Gaussian proposal distribution and
Daniel@0 37 accepted or rejected according to the Metropolis criterion.
Daniel@0 38
Daniel@0 39 <p><CODE>samples = metrop(f, x, options, [], p1, p2, ...)</CODE> allows
Daniel@0 40 additional arguments to be passed to <CODE>f()</CODE>. The fourth argument is
Daniel@0 41 ignored, but is included for compatibility with <CODE>hmc</CODE> and the
Daniel@0 42 optimisers.
Daniel@0 43
Daniel@0 44 <p><CODE>[samples, energies, diagn] = metrop(f, x, options)</CODE> also returns
Daniel@0 45 a log of the energy values (i.e. negative log probabilities) for the
Daniel@0 46 samples in <CODE>energies</CODE> and <CODE>diagn</CODE>, a structure containing
Daniel@0 47 diagnostic information (position and
Daniel@0 48 acceptance threshold) for each step of the chain in <CODE>diagn.pos</CODE> and
Daniel@0 49 <CODE>diagn.acc</CODE> respectively. All candidate states (including rejected
Daniel@0 50 ones) are stored in <CODE>diagn.pos</CODE>.
Daniel@0 51
Daniel@0 52 <p><CODE>s = metrop('state')</CODE> returns a state structure that contains the
Daniel@0 53 state of the two random number generators <CODE>rand</CODE> and <CODE>randn</CODE>.
Daniel@0 54 These are contained in fields
Daniel@0 55 <CODE>randstate</CODE>,
Daniel@0 56 <CODE>randnstate</CODE>.
Daniel@0 57
Daniel@0 58 <p><CODE>metrop('state', s)</CODE> resets the state to <CODE>s</CODE>. If <CODE>s</CODE> is an integer,
Daniel@0 59 then it is passed to <CODE>rand</CODE> and <CODE>randn</CODE>.
Daniel@0 60 If <CODE>s</CODE> is a structure returned by <CODE>metrop('state')</CODE> then
Daniel@0 61 it resets the generator to exactly the same state.
Daniel@0 62
Daniel@0 63 <p>The optional parameters in the <CODE>options</CODE> vector have the following
Daniel@0 64 interpretations.
Daniel@0 65
Daniel@0 66 <p><CODE>options(1)</CODE> is set to 1 to display the energy values and rejection
Daniel@0 67 threshold at each step of the Markov chain. If the value is 2, then the
Daniel@0 68 position vectors at each step are also displayed.
Daniel@0 69
Daniel@0 70 <p><CODE>options(14)</CODE> is the number of samples retained from the Markov chain;
Daniel@0 71 default 100.
Daniel@0 72
Daniel@0 73 <p><CODE>options(15)</CODE> is the number of samples omitted from the start of the
Daniel@0 74 chain; default 0.
Daniel@0 75
Daniel@0 76 <p><CODE>options(18)</CODE> is the variance of the proposal distribution; default 1.
Daniel@0 77
Daniel@0 78 <p><h2>
Daniel@0 79 Examples
Daniel@0 80 </h2>
Daniel@0 81 The following code fragment samples from the posterior distribution of
Daniel@0 82 weights for a neural network.
Daniel@0 83 <PRE>
Daniel@0 84
Daniel@0 85 w = mlppak(net);
Daniel@0 86 [samples, energies] = metrop('neterr', w, options, 'netgrad', net, x, t);
Daniel@0 87 </PRE>
Daniel@0 88
Daniel@0 89
Daniel@0 90 <p><h2>
Daniel@0 91 Algorithm
Daniel@0 92 </h2>
Daniel@0 93
Daniel@0 94 The algorithm follows the procedure outlined in Radford Neal's technical
Daniel@0 95 report CRG-TR-93-1 from the University of Toronto.
Daniel@0 96
Daniel@0 97 <p><h2>
Daniel@0 98 See Also
Daniel@0 99 </h2>
Daniel@0 100 <CODE><a href="hmc.htm">hmc</a></CODE><hr>
Daniel@0 101 <b>Pages:</b>
Daniel@0 102 <a href="index.htm">Index</a>
Daniel@0 103 <hr>
Daniel@0 104 <p>Copyright (c) Ian T Nabney (1996-9)
Daniel@0 105
Daniel@0 106
Daniel@0 107 </body>
Daniel@0 108 </html>