wolffd@0
|
1 <html>
|
wolffd@0
|
2 <head>
|
wolffd@0
|
3 <title>
|
wolffd@0
|
4 Netlab Reference Manual hmc
|
wolffd@0
|
5 </title>
|
wolffd@0
|
6 </head>
|
wolffd@0
|
7 <body>
|
wolffd@0
|
8 <H1> hmc
|
wolffd@0
|
9 </H1>
|
wolffd@0
|
10 <h2>
|
wolffd@0
|
11 Purpose
|
wolffd@0
|
12 </h2>
|
wolffd@0
|
13 Hybrid Monte Carlo sampling.
|
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 = hmc(f, x, options, gradf)
|
wolffd@0
|
21 samples = hmc(f, x, options, gradf, P1, P2, ...)
|
wolffd@0
|
22 [samples, energies, diagn] = hmc(f, x, options, gradf)
|
wolffd@0
|
23 s = hmc('state')
|
wolffd@0
|
24 hmc('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 <CODE>samples = hmc(f, x, options, gradf)</CODE> uses a
|
wolffd@0
|
32 hybrid Monte Carlo algorithm to sample from the distribution <CODE>p ~ exp(-f)</CODE>,
|
wolffd@0
|
33 where <CODE>f</CODE> is the first argument to <CODE>hmc</CODE>.
|
wolffd@0
|
34 The Markov chain starts at the point <CODE>x</CODE>, and the function <CODE>gradf</CODE>
|
wolffd@0
|
35 is the gradient of the `energy' function <CODE>f</CODE>.
|
wolffd@0
|
36
|
wolffd@0
|
37 <p><CODE>hmc(f, x, options, gradf, p1, p2, ...)</CODE> allows
|
wolffd@0
|
38 additional arguments to be passed to <CODE>f()</CODE> and <CODE>gradf()</CODE>.
|
wolffd@0
|
39
|
wolffd@0
|
40 <p><CODE>[samples, energies, diagn] = hmc(f, x, options, gradf)</CODE> also returns
|
wolffd@0
|
41 a log of the energy values (i.e. negative log probabilities) for the
|
wolffd@0
|
42 samples in <CODE>energies</CODE> and <CODE>diagn</CODE>, a structure containing
|
wolffd@0
|
43 diagnostic information (position, momentum and
|
wolffd@0
|
44 acceptance threshold) for each step of the chain in <CODE>diagn.pos</CODE>,
|
wolffd@0
|
45 <CODE>diagn.mom</CODE> and
|
wolffd@0
|
46 <CODE>diagn.acc</CODE> respectively. All candidate states (including rejected ones)
|
wolffd@0
|
47 are stored in <CODE>diagn.pos</CODE>.
|
wolffd@0
|
48
|
wolffd@0
|
49 <p><CODE>[samples, energies, diagn] = hmc(f, x, options, gradf)</CODE> also returns the
|
wolffd@0
|
50 <CODE>energies</CODE> (i.e. negative log probabilities) corresponding to the samples.
|
wolffd@0
|
51 The <CODE>diagn</CODE> structure contains three fields:
|
wolffd@0
|
52
|
wolffd@0
|
53 <p><CODE>pos</CODE> the position vectors of the dynamic process.
|
wolffd@0
|
54
|
wolffd@0
|
55 <p><CODE>mom</CODE> the momentum vectors of the dynamic process.
|
wolffd@0
|
56
|
wolffd@0
|
57 <p><CODE>acc</CODE> the acceptance thresholds.
|
wolffd@0
|
58
|
wolffd@0
|
59 <p><CODE>s = hmc('state')</CODE> returns a state structure that contains the state of the
|
wolffd@0
|
60 two random number generators <CODE>rand</CODE> and <CODE>randn</CODE> and the momentum of
|
wolffd@0
|
61 the dynamic process. These are contained in fields
|
wolffd@0
|
62 <CODE>randstate</CODE>, <CODE>randnstate</CODE>
|
wolffd@0
|
63 and <CODE>mom</CODE> respectively. The momentum state is
|
wolffd@0
|
64 only used for a persistent momentum update.
|
wolffd@0
|
65
|
wolffd@0
|
66 <p><CODE>hmc('state', s)</CODE> resets the state to <CODE>s</CODE>. If <CODE>s</CODE> is an integer,
|
wolffd@0
|
67 then it is passed to <CODE>rand</CODE> and <CODE>randn</CODE> and the momentum variable
|
wolffd@0
|
68 is randomised. If <CODE>s</CODE> is a structure returned by <CODE>hmc('state')</CODE> then
|
wolffd@0
|
69 it resets the generator to exactly the same state.
|
wolffd@0
|
70
|
wolffd@0
|
71 <p>The optional parameters in the <CODE>options</CODE> vector have the following
|
wolffd@0
|
72 interpretations.
|
wolffd@0
|
73
|
wolffd@0
|
74 <p><CODE>options(1)</CODE> is set to 1 to display the energy values and rejection
|
wolffd@0
|
75 threshold at each step of the Markov chain. If the value is 2, then the
|
wolffd@0
|
76 position vectors at each step are also displayed.
|
wolffd@0
|
77
|
wolffd@0
|
78 <p><CODE>options(5)</CODE> is set to 1 if momentum persistence is used; default 0, for
|
wolffd@0
|
79 complete replacement of momentum variables.
|
wolffd@0
|
80
|
wolffd@0
|
81 <p><CODE>options(7)</CODE> defines the trajectory length (i.e. the number of leap-frog
|
wolffd@0
|
82 steps at each iteration). Minimum value 1.
|
wolffd@0
|
83
|
wolffd@0
|
84 <p><CODE>options(9)</CODE> is set to 1 to check the user defined gradient function.
|
wolffd@0
|
85
|
wolffd@0
|
86 <p><CODE>options(14)</CODE> is the number of samples retained from the Markov chain;
|
wolffd@0
|
87 default 100.
|
wolffd@0
|
88
|
wolffd@0
|
89 <p><CODE>options(15)</CODE> is the number of samples omitted from the start of the
|
wolffd@0
|
90 chain; default 0.
|
wolffd@0
|
91
|
wolffd@0
|
92 <p><CODE>options(17)</CODE> defines the momentum used when a persistent update of
|
wolffd@0
|
93 (leap-frog) momentum is used. This is bounded to the interval [0, 1).
|
wolffd@0
|
94
|
wolffd@0
|
95 <p><CODE>options(18)</CODE> is the step size used in leap-frogs; default 1/trajectory
|
wolffd@0
|
96 length.
|
wolffd@0
|
97
|
wolffd@0
|
98 <p><h2>
|
wolffd@0
|
99 Examples
|
wolffd@0
|
100 </h2>
|
wolffd@0
|
101 The following code fragment samples from the posterior distribution of
|
wolffd@0
|
102 weights for a neural network.
|
wolffd@0
|
103 <PRE>
|
wolffd@0
|
104
|
wolffd@0
|
105 w = mlppak(net);
|
wolffd@0
|
106 [samples, energies] = hmc('neterr', w, options, 'netgrad', net, x, t);
|
wolffd@0
|
107 </PRE>
|
wolffd@0
|
108
|
wolffd@0
|
109
|
wolffd@0
|
110 <p><h2>
|
wolffd@0
|
111 Algorithm
|
wolffd@0
|
112 </h2>
|
wolffd@0
|
113
|
wolffd@0
|
114 The algroithm follows the procedure outlined in Radford Neal's technical
|
wolffd@0
|
115 report CRG-TR-93-1 from the University of Toronto. The stochastic update of
|
wolffd@0
|
116 momenta samples from a zero mean unit covariance gaussian.
|
wolffd@0
|
117
|
wolffd@0
|
118 <p><h2>
|
wolffd@0
|
119 See Also
|
wolffd@0
|
120 </h2>
|
wolffd@0
|
121 <CODE><a href="metrop.htm">metrop</a></CODE><hr>
|
wolffd@0
|
122 <b>Pages:</b>
|
wolffd@0
|
123 <a href="index.htm">Index</a>
|
wolffd@0
|
124 <hr>
|
wolffd@0
|
125 <p>Copyright (c) Ian T Nabney (1996-9)
|
wolffd@0
|
126
|
wolffd@0
|
127
|
wolffd@0
|
128 </body>
|
wolffd@0
|
129 </html> |