-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomputeError.m
More file actions
40 lines (34 loc) · 1.53 KB
/
computeError.m
File metadata and controls
40 lines (34 loc) · 1.53 KB
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
function sumSquareErrors = computeError(d0,rho)
% Get error of model-data fit to scaling of CGE(d) parameters
%-------------------------------------------------------------------------------
includeF0 = false;
% Simulate model with specified parameters:
params = GiveMeDefaultParams();
% Over-ride the d0scaling factor and rho values:
params.d0scalingFactor = d0;
params.ensembleParams.rho = rho;
[maxExtent,paramStruct] = simulateGrid(params,false);
lambdaModel = cellfun(@(x)1/x.n,paramStruct);
strengthModel = cellfun(@(x)x.A,paramStruct);
f0Model = cellfun(@(x)x.B,paramStruct);
%-------------------------------------------------------------------------------
% Load results from fitted data:
%-------------------------------------------------------------------------------
params = struct();
params.doSubsample = true;
params.thisBrainDiv = 'brain';
params.thisCellType = 'allCellTypes';
params.includeAdult = false;
[params,fittedParams,CIs,goodTimePoint] = LoadParameterFits(params);
lambdaEmpirical = cellfun(@(x)1/x.n,fittedParams);
strengthEmpirical = cellfun(@(x)x.A,fittedParams);
f0Empirical = cellfun(@(x)x.B,fittedParams);
if includeF0
sumSquareErrors = sum(abs((lambdaEmpirical-lambdaModel)./lambdaEmpirical)) + ...
sum(abs((strengthEmpirical-strengthModel)./strengthEmpirical)) + ...
sum(abs((f0Empirical-f0Model)./f0Empirical));
else
sumSquareErrors = sum(abs((lambdaEmpirical-lambdaModel)./lambdaEmpirical)) + ...
sum(abs((strengthEmpirical-strengthModel)./strengthEmpirical));
end
end