1function d = map_dist_lag1(MAPA,MAPB,alA,alB)
2% d=map_dist_lag1(MAPA,MAPB,alA,alB) - Lag-1 joint density L2 distance
3% via Kronecker/Lyapunov formulation. Equivalent to map_dist(MAPA,MAPB,1).
6% G. Horvath,
"Measuring the distance between MAPs and some
7% applications," in Proc. ASMTA 2015, LNCS 9081, pp. 95-109.
11% MAPA: first MAP in the form of {D0,D1}
12% MAPB: second MAP in the form of {D0,D1}
13% alA,alB: (optional) stationary vectors at arrival epochs
16% d: squared L2 distance of lag-1 joint densities
18A0=MAPA{1}; A1=MAPA{2};
19B0=MAPB{1}; B1=MAPB{2};
20if nargin<4, alB=map_pie(MAPB); end
21if nargin<3, alA=map_pie(MAPA); end
26Z_AB = lyap(A0
', B0, alA'*alB);
27Z_AA = lyap(A0
', A0, alA'*alA);
28Z_BB = lyap(B0
', B0, alB'*alB);
30X_AB = lyap(A0, B0
', a*b');
31X_AA = lyap(A0, A0
', a*a');
32X_BB = lyap(B0, B0
', b*b');
34vA1 = reshape(A1, numel(A1), 1);
35vB1 = reshape(B1, numel(B1), 1);
37d = vB1
'*kron(X_BB,Z_BB)*vB1 + vA1'*kron(X_AA,Z_AA)*vA1 ...
38 - 2*vA1
'*kron(X_AB,Z_AB)*vB1;