forked from sjgershm/mfit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mfit_opts.m
36 lines (33 loc) · 1.09 KB
/
mfit_opts.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
function opts = mfit_opts(opts)
% Generate default options.
%
% USAGE: opts = mfit_opts([opts])
%
% INPUTS:
% opts - options structure. If empty, all fields will be set to defaults.
% .M - number of samples (default: 10000)
% .vectorize - is likelihood function vectorized? (default: 1)
% .hierarchical - use hierarchical model? (default: 1)
% .sd - mean of exponential prior on standard deviations for
% hierarchical model (default: 1)
% .nStarts - number of random starts for optimization (default: 2)
%
% OUTPUTS:
% opts - complete options structure
%
% Sam Gershman, June 2015
def_opts.M = 10000;
def_opts.vectorize = 1;
def_opts.hierarchical = 1;
def_opts.sd = 1;
def_opts.nStarts = 2;
if nargin < 1 || isempty(opts)
opts = def_opts;
else
F = fieldnames(def_opts);
for f = 1:length(F)
if ~isfield(opts,F{f})
opts.(F{f}) = def_opts.(F{f});
end
end
end