1function [fit,m3pps] = m3pp_interleave_fitc_theoretical(
MMAP, t, tinf, mapping)
2% Interleaves k M3PP to fit a multi-
class trace with m
classes.
5% - t: finite time scale
6% - tinf: near-infinite time scale
7% - mapping: m x k binary matrix mapping the m
classes to k m3pp (optional,
13% by
default,
map one
class per m3pp
18% by
default, quadratic
21 SIGMA = mmap_count_mcov(
MMAP,tinf);
24 variance = diag(SIGMA);
26 k = pool(maxpos(variance(pool)));
28 pool(find(k == pool))=[];
30 if SIGMA(k,h)/sqrt(SIGMA(k,k)*SIGMA(h,h)) >= delta
32 pool(find(h == pool))=[];
41if size(mapping,1) ~= m
42 error(
'Number of classes does not match mapping.');
49rowsum = sum(mapping,2);
50if max(rowsum) > 1 || min(rowsum) < 1
51 error(
'Invalid mapping');
54fprintf(
'Fitting %d classes with %d M3PP(2,m_j) processes\n', m, k);
57a = map_count_mean(
MMAP,1);
60ac = mmap_count_mean(
MMAP, 1);
65 f{j} = mapping(:,j) == 1;
68% total rates of each m3pp
71 av(j) = sum(ac(mapping(:,j) == 1));
74% per-
class rates within each m3pp
80% per-
class IDC(t) e IDC(inf)
81vtc = mmap_count_var(
MMAP, t);
82vinfc = mmap_count_var(
MMAP, tinf);
84binfc = vinfc ./ (ac * tinf);
86% compute covariance between
classes
87stc = mmap_count_mcov(
MMAP, t);
89% compute IDC(t) e IDC(inf)
for each m3pp
93 % group
classes that belong to j and
classes that don
't belong to j
98 mmap2{3} = zeros(n,n);
101 mmap2{3} = mmap2{3} + MMAP{2+i};
104 mmap2{4} = mmap2{2} - mmap2{3};
106 vtv = mmap_count_var(mmap2,t);
107 vinfv = mmap_count_var(mmap2,tinf);
108 btv(j) = vtv(1) ./ (av(j)*t);
109 binfv(j) = vinfv(1) ./ (av(j)*tinf);
112vtc = mmap_count_var(MMAP,t);
115 % number of classes in this partition
116 mj = sum(mapping(:,j));
121 % simple case, this is the only class
131 m3pp3{3} = MMAP{2+i};
132 % other classes in the same partition
133 m3pp3{4} = zeros(size(MMAP{1},1));
135 if h ~= i && mapping(h,j) == 1
136 m3pp3{4} = m3pp3{4} + MMAP{2+h};
139 % classes in other partitions
140 m3pp3{5} = m3pp3{2} - m3pp3{3} - m3pp3{4};
141 % marginal covariance within the partition
142 covji = mmap_count_mcov(m3pp3, t);
143 gtc{j}(n) = vtc(i) + covji(1,2);
150[fit,m3pps] = m3pp_interleave_fitc(av, btv, binfv, ...
151 acc, gtc, t, tinf, mapping);