-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpcm_optimalAlgorithm.m
executable file
·33 lines (32 loc) · 1.25 KB
/
pcm_optimalAlgorithm.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
function M = pcm_optimalAlgorithm(M);
% Determine the fastest fitting algorithm for each of the PCM
% model - if not given.
numModels = numel(M);
for m=1:numModels
if (~isfield(M{m},'fitAlgorithm'))
switch (M{m}.type)
case 'component'
if (isfield(M{m},'Gd'))
M{m}.fitAlgorithm = 'NR';
else
M{m}.fitAlgorithm = 'NR';
end;
case 'feature'
M{m}.fitAlgorithm = 'NR';
case 'nonlinear'
M{m}.fitAlgorithm = 'NR';
case 'freechol' % A free cholesky model, to estimate parameters: Line search better here
M{m}.fitAlgorithm = 'minimize';
case 'fixed'
M{m}.MM = pcm_diagonalize(M{m}.Gc); %Model matrix for diagonalisation
M{m}.fitAlgorithm = 'NR';
M{m}.numGparams = 0;
case 'freedirect' % A free model (arbitrary G) directly estimated from crossvalidated G
M{m}.fitAlgorithm = 'NR';
M{m}.numGparams=0;
end;
if (M{m}.numGparams>20)
M{m}.fitAlgorithm = 'minimize';
end;
end;
end; % Over models