1function [fit,m3pps] = m3pp_interleave_fitc_trace(T, A, t, tinf, mapping)
2% Interleaves k M3PP to fit a multi-
class trace with m
classes.
4% - T: inter-arrival time
6% - t: finite time scale
7% - tinf: near-infinite time scale
8% - mapping: m x k binary matrix mapping the m
classes to k m3pp (optional,
16% by
default choose time scales as follows
19 tinf = max(10*t, (sum(T)-T(1)) / 100);
21% compute counting process at resolution t1 and tinf
22Nt = mtrace_iat2counts(T, A, t);
23Ninf = mtrace_iat2counts(T, A, tinf);
25% by
default, %%
map one
class per m3pp
32 variance = diag(SIGMA);
34 k = pool(maxpos(variance(pool)));
36 pool(find(k == pool))=[];
38 if SIGMA(k,h)/sqrt(SIGMA(k,k)*SIGMA(h,h)) >= delta
40 pool(find(h == pool))=[];
47% check mapping consistency
48if size(mapping,1) ~= m
49 error(
'Number of classes does not match mapping.');
56rowsum = sum(mapping,2);
57if max(rowsum) > 1 || min(rowsum) < 1
58 error(
'Invalid mapping');
61fprintf(
'Fitting %d classes with %d M3PP(2,m_j) processes\n', m, k);
69 pc(j) = sum(A==L(j))/length(A);
76 f{j} = mapping(:,j) == 1;
79% total rates of each m3pp
82 av(j) = sum(ac(f{j}));
85% per-
class rates within each m3pp
91% compute IDC(t) e IDC(inf)
for each m3pp
95 % counting processes
for the j-th m3pp
96 Ntj = zeros(size(Nt,1),1);
97 Ninfj = zeros(size(Ninf,1),1);
99 % sum
classes fitted by
this m3pp
102 Ninfj = Ninfj + Ninf(:,i);
106 btv(j) = var(Ntj)/(av(j)*t);
107 binfv(j) = var(Ninfj)/(av(j)*tinf);
110% compute per-
class variance plus marginal covariance within each m3pp
113 % number of
classes fitted with
this m3pp
114 mj = sum(mapping(:,j));
116 fj = mapping(:,j) == 1;
117 % per-
class variance of this m3pp
118 vtj = var(Nt(:,fj))
';
119 % per class variance + marginal covariance of this m3pp
123 % if class i is mapped to the j-th m3pp
125 covtji = cov(Nt(:,i), sum(Nt(:,fj),2)-Nt(:,i));
126 stj(h) = covtji(1,2);
130 % vector of per-class variance plus margina covariance
134[fit,m3pps] = m3pp_interleave_fitc(av, btv, binfv, ...
135 acc, gtc, t, tinf, mapping);