-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim_B1.m
103 lines (79 loc) · 2.37 KB
/
sim_B1.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
function sim_B1(i)
% outliers in evidence space
mode = '';
if nargin==0, mode = 'sumfig'; end
if nargin==1, mode = 'run'; end
getdefaults('addpath');
switch mode
case 'run'
run(i);
case 'sumfig'
sumfig;
otherwise
error('Unknown mode: %s',mode);
end
end
function run(ii)
nsim = 20;
if nargin<1, ii=nsim; end
run_out(nsim,1,ii);
run_out(nsim,2,ii);
run_out(nsim,3,ii);
end
function run_out(nsim,nout,ii)
simcat = 'sim_B';
symname = 'rwkf';
simstr = sprintf('%s_outlier%d',symname,nout);
models = {'model_rw1','model_kf1'};
pnames = { {'\alpha','\beta'},{'\omega','\beta'} };
modelnames = {'Reinforcement learning','Kalman filter'};
mnames = {'RL','KF'};
normx1 = {@(x)1./(1+exp(-x)), @exp};
normx2 = {@exp,@exp};
normx = {normx1,normx2};
sim_sim_B1(ii,simcat,simstr,models);
if ii(end)~=nsim, return; end
sim_wrap(nsim,simcat,simstr,modelnames,mnames,pnames,normx);
end
function sumfig
simcat = 'sim_A';
fitsimstrs = {'fit_rwkf[10 30]'};
fsimfit0 = fullfile(getdefaults('pipedir'),simcat,fitsimstrs);
simcat = 'sim_B';
fitsimstrs = {'fit_rwkf_outlier1','fit_rwkf_outlier2','fit_rwkf_outlier3'};
fsimfits = [fsimfit0 fullfile(getdefaults('pipedir'),simcat,fitsimstrs)];
nout = 0:3;
[corrBMS,methods] = sim_stat_B1(fsimfits);
% close all;
fig_plot_evidence(corrBMS,nout,methods);
set(gcf,'name',mfilename);
end
function fig_plot_evidence(corrBMSs,xgroups,methods)
[fs,fst,fsl,fsy,fsalpha,fsxt,fsA,fn,fnt,xsA,ysA,fpos0,siz0,colmap,alf,cmaphbi,bw,colmapsim]=fig_plot_properties; %#ok<*ASGLU>
fpos = [.3 .35];
siz = fpos./fpos0(3:4).*siz0;
bw = .7*bw;
figure;
set(gcf,'units','centimeters');
fsiz = get(gcf,'position');
fsiz(3:4) = siz;
fsiz(1:2) = fpos0(1:2).*fsiz(1:2);
set(gcf,'position',fsiz);
set(gcf,'units','normalized');
%---------
mx = ceil(max(max(corrBMSs)));
ms = mx/5;
errorbarKxN(corrBMSs',0*corrBMSs',xgroups,'',colmap,0,bw);
set(gca,'fontsize',fs,'fontname',fn);
ylabel('Correct model selection %','fontsize',fsy);
title('Robustness of model selection to outliers','fontsize',fst,'fontname',fnt);
alpha(gca,alf);
set(gca,'ytick',0:ms:mx);
set(gca,'yticklabel',0:ms:mx);
ylim([0 1.2*mx]);
ax = ancestor(gca, 'axes');
xaxes = get(ax,'XAxis');
set(xaxes,'fontsize',fsxt);
legend(methods,'location','north','fontsize',fsl,'Orientation','horizontal');
xlabel('Number of outliers','fontsize',fsy);
end