forked from lawrennd/gpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpsimSampleHMC.m
49 lines (41 loc) · 1.07 KB
/
gpsimSampleHMC.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function samples = gpsimSampleHMC(model, display, iters);
% GPSIMSAMPLEHMC Do HMC sampling for the GPSIM model.
% FORMAT
% DESC performs HMC sampling for the Gaussian process single input
% motif model for a given number of iterations.
% ARG model : the model to be optimised.
% ARG display : whether or not to display while optimisation
% proceeds, set to 2 for the most verbose and 0 for the least
% verbose.
% ARG iters : number of samples to return.
% RETURN samples : the samples.
%
% SEEALSO : hmc, gpsimCreate, gpsimGradient, gpsimObjective
%
% COPYRIGHT : Neil D. Lawrence, 2006
%
% MODIFICATIONS : Antti Honkela, 2007
% SHEFFIELDML
if nargin < 3
iters = 2000;
if nargin < 2
display = 1;
end
end
params = modelExtractParam(model);
options = optOptions;
if display
options(1) = display;
if length(params) <= 100
options(9) = 1;
end
end
% Momentum persistence
options(5) = 1;
% Leapfrog steps
options(7) = 10;
options(18) = .01;
% Number of samples to return
options(14) = iters;
samples = hmc('modelObjective', params, options, ...
'modelGradient', model);