-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbolin_wallin.m
More file actions
64 lines (55 loc) · 1.87 KB
/
Copy pathbolin_wallin.m
File metadata and controls
64 lines (55 loc) · 1.87 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function loc = bolin_wallin(dis, params)
% This function calculates the Bolin & Wallin localization function,
% which is equal to the normalized volume of intersection of two spheres with
% centers d units apart, where one sphere has radius cmax and the other has
% radius cmin. The normalization is chosen so that the normalized volume of
% two colocated spheres (d=0) with the same radius (cmax=cmin) is 1.
% This localization function is defined in Bolin and Wallin (2016), Section 2.1
% and rewritten in Eqs. (6-8) in Stanley et al., (2021)
%
% INPUTS:
% dis = distance
% params is a struct which holds scalar localization parameters:
% rXX is the localization radius for process X
% rYY is the localization radius for process Y
% Ny is the number of state variables in process Y
% Nx is the number of state variables in process X
% beta is the cross-localization weight factor
%
% OUTPUT:
% loc = localization matrix
%
% Author: Zofia Stanley
% Load parameters
rXX = params.rXX;
rYY = params.rYY;
Ny = params.Ny;
Nx = params.Nx;
b = params.beta;
% Divide loc. rad. by to 2 to get kernel rad.
cX = rXX / 2;
cY = rYY / 2;
% Rescale beta
betamax = bolin_wallin_beta_max(params);
beta_rescaled = b / betamax ;
assert(b<=betamax, sprintf('beta (%0.2g) must be less than beta max (%0.2g).', b, betamax))
% We assume a symmetric distance matrix
dYY = dis(1:Ny, 1:Ny);
dXX = dis(Ny+1:end, Ny+1:end);
dXY = dis(Ny+1:end, 1:Ny);
% Within-component localization
locYY = bolin_wallin_univariate(dYY, cY);
locXX = bolin_wallin_univariate(dXX, cX);
% Cross-localization
if cX == cY
locXY = bolin_wallin_univariate(dXY, cY);
else
locXY = bolin_wallin_cross(dXY, cY, cX);
end
% Put submatrices back together
loc = zeros(Ny+Nx);
loc(1:Ny, 1:Ny) = locYY;
loc(Ny+1:end, Ny+1:end) = locXX;
loc(Ny+1:end, 1:Ny) = beta_rescaled .* locXY;
loc(1:Ny, Ny+1:end) = beta_rescaled .* locXY';
end