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