-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake_cdf_example.m
executable file
·71 lines (58 loc) · 1.75 KB
/
make_cdf_example.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
clear
close all
load fit_sim.mat
rtCor = rt(resp>0);
[N,X] = hist(rtCor,nbins(rtCor)+10);
dx = X(2)-X(1);
NN = cumsum(N);
acc = sum(resp>0)/length(resp);
NN = NN/NN(end)*acc;
%bar(X,NN,'b')
figure(1)
bar(X,N/trapz(X,N),'b')
%% Empirical distribution function
figure(2)
[ff,xx,flo,fup] = ecdf(rtCor,'alpha',.05,'bounds','on');
h1 = stairs(xx,ff,'linewidth',1);
%% Run msddm code, quickest just to type these in, but you can look
%% at recoveredParameters variable
a = [0.2132 0.5898];
s = [1 1];
th = [1.4987 1.995];
x0dist = 1;
dl = [0 1.4997];
tFinal = 13;
x0 = -0.1133;
T0 = 0;
[tArray,~,yPlus,yMinus] = multistage_ddm_fpt_dist(...
a,s,th,x0,x0dist,dl,tFinal);
figure(2)
hold on
h2 = plot(tArray+T0,yPlus/yPlus(end),'r','Linewidth',2);
stairs(xx,flo,'b:','linewidth',1);
stairs(xx,fup,'b:','linewidth',1);
for jj = 1:length(yPlus)-1
yy(jj) = (yPlus(jj+1)-yPlus(jj))/(tArray(jj+1)-tArray(jj));
end
% dt = tArray(3)-tArray(2);
tt = tArray(2:end);
% yy = diff(yPlus)/dt;
figure(1)
hold on
plot(tt+T0,yy/trapz(tt,yy),'r','Linewidth',2)
drawnow
figure(1)
title('Simulated RT histogram and model fit','FontSize',18,'FontWeight','bold')
xlabel('Reaction time (sec)','FontSize',18)
ylabel('Frequency','FontSize',18)
%legend('Experimental','2-stage DDM','FontSize',18)
saveas(gcf,'figures/rt_simfit.eps','psc2')
saveas(gcf,'figures/rt_simfit.fig','fig')
figure(2)
title('Simulated RT CDF and model fit','FontSize',18,'FontWeight','bold')
xlabel('Reaction time (sec)','FontSize',18)
ylabel('','FontSize',18)
%legend([h1 h2],'Empirical distribution function','2-stage DDM CDF','Location','NorthWest')
saveas(gcf,'figures/rtDF_simfit.eps','psc2')
saveas(gcf,'figures/rtDF_simfit.fig','fig')
return