-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanaDynNN.m
102 lines (54 loc) · 2.47 KB
/
anaDynNN.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
function outNNana = anaDynNN(PARAMS, expDists,simuDists)
%{
anaDynNN: Compares the experimental and simulated populations, the 2 inputs
share the same structure of N fields for N DeltaN and a subfield of
allDistances
INPUT
expDists - See outNNdispersion variable in the mergeDynNN function.
Containes the merged distances for all timepoints where DeltaT is the
desired one.
simuDists - See outNNdispersion variable in the mergeDynNN function.
Containes the merged distances for all timepoints where DeltaT is the
desired one. For one RS simulation only
OUTPUT
outNNana - Structure containing all the new analyses sorted by type (RMSE,
other) and then by deltaT
%}
% % for dev only
% expDists = NNdispersion.exp;
% simuDists = NNdispersion.simu.(pairString);
% Initialize structures
outNNana = {};
RMSEstruct = {};
DTfields = fieldnames(simuDists);
for DTfield = 1:numel(DTfields) % for each DeltaT
% % if using filters before analysis => try with pchip (beware of first false line output...)
% [foo, bar] = ecdf(reshape(inNNdispersionSimu.deltaT4.allDistances,[],1));
% tempFormSimu(:,1) = foo;
% tempFormSimu(:,2) = bar;
% temp = pchip(tempFormSimu(:,2),tempFormSimu(:,1),0:150);
% plot(0:150,temp)
%
%% RMSE calculations
if PARAMS.anaGlobal.doRMSE
% Calculate simulated and experimental cdfs
[RMSEstruct.expY, RMSEstruct.expX] = ecdf(reshape(expDists.(DTfields{DTfield}).allDistances,[],1));
RMSEstruct.expX(1) = 0;
[RMSEstruct.simuY, RMSEstruct.simuX] = ecdf(reshape(simuDists.(DTfields{DTfield}).allDistances,[],1));
RMSEstruct.simuX(1) = 0;
% Interpolate the simulated data against the experimental ones, could do
% the opposite or use a single array of positions using the same function
% (better than spline in that particular case)
RMSEstruct.interpSimuY = pchip(RMSEstruct.simuX,RMSEstruct.simuY,RMSEstruct.expX);
RMSEstruct.diffCdf = RMSEstruct.expY - RMSEstruct.interpSimuY;
RMSEstruct.RMSE = rms(RMSEstruct.diffCdf);
outNNana.RMSE.(DTfields{DTfield}) = RMSEstruct;
% To display for construction
% figure
% plot(RMSEstruct.expX,RMSEstruct.expY)
% hold on
% plot(RMSEstruct.simuX,RMSEstruct.simuY)
% plot(RMSEstruct.expX,RMSEstruct.smoothedSimuY, 'o')
end
end
end