-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_params.m
56 lines (50 loc) · 1.69 KB
/
check_params.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
50
51
52
53
54
55
function p = check_params(opt)
if ~isfield(opt,'X0_RMHMC') || ~isfield(opt,'X0_MH')
error('starting estimates opt.XO_RMHMC and opt.XO_MH must be defined');
end
% fill in generic defaults
def.nGibbsIter = 10000;
def.WriteInterim = true;
%def.BurnIn = 1000;
def.PriorParam = [2,2];
def.OptimiseTheta = false;
def.CovFunc = 'covfunc_sum'; %'covfunc_wsum';
def.OutputFilename = []; % leave blank for no output
def.UseRMHMC = false;
def.UseGMassForHMC = false; % Only used if UseRMHMC = false
% set parameters for testing ...
def.TestInterval = 2; % factor to thin Markov chain by
def.nTestSamples = 1; % How many samples of f to draw from N(mu_s,S_s)
flds = fields(def);
for i = 1:length(flds)
fld = flds(i);
if ~isfield(opt,fld)
warning(['option ',char(fld),' not specified. Using default value']);
eval(['opt.',char(fld),'=def.',char(fld),';']);
end
end
% fill in defaults for RMHMC
def.rmhmc.NumOfIterations = 1;
def.rmhmc.StepSize = 0.5;
def.rmhmc.NumOfLeapFrogSteps = 10;
def.rmhmc.NumOfNewtonSteps = 4;
flds = fields(def.rmhmc);
for i = 1:length(flds)
fld = flds(i);
if ~isfield(opt.rmhmc,char(fld))
warning(['option ',char(fld),' not specified for RMHMC. Using default value']);
eval(['opt.rmhmc.',char(fld),'=def.rmhmc.',char(fld),';']);
end
end
% fill in defaults for MH
def.mh.StepSize = 0.2;
flds = fields(def.mh);
for i = 1:length(flds)
fld = flds(i);
if ~isfield(opt.mh,char(fld))
warning(['option ',char(fld),' not specified for MH. Using default value']);
eval(['opt.mh.',char(fld),'=def.mh.',char(fld),';']);
end
end
p = opt;
end