comparison toolboxes/FullBNT-1.0.7/nethelp3.3/metrop.htm @ 0:e9a9cd732c1e tip

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