1function [fit] = m3pp2m_fitc_trace(T, A, method, t1, tinf)
2% Fits the theoretical characteristics of a
MMAP(n,m) with a M3PP(2,m).
4% - mmap: the
MMAP(n,m) to fit with a M3PP(2,m)
5% - method:
'exact_delta',
'approx_delta',
'approx_cov' or
'approx_ag'
11 method =
'approx_delta';
14if strcmp(method,
'approx_cov') && m > 2
15 error(
'Approximate covariance fitting only supported for two classes.');
22 tinf = max(10*t1, (TC(end)-TC(1)) / 100);
25t3 = tinf; %
this controls the approximation - GC changed from t1 to tinf
27fprintf(
'Computing counting process at resolution %f\n', t1);
28mNt1 = mtrace_iat2counts(T, A, t1);
30fprintf(
'Computing counting process at resolution %f\n', tinf);
31mNtinf = mtrace_iat2counts(T, A, tinf);
36Ntinf = sum(mNtinf, 2);
44 ai(i) = a * sum(A == labels(i))/length(A);
47fprintf(
'Rate: %f\n', a);
49% joint-process charactersitics
52binf = var(Ntinf)/(a*tinf);
53mt2 = [mean(Nt2), mean(Nt2.^2), mean(Nt2.^3)];
54m3t2 = mt2(3) - 3*mt2(2)*mt2(1) + 2*mt2(1)^3;
56if strcmp(method,
'exact_delta') == 1 || strcmp(method,
'approx_delta') == 1
57 % per-
class variance differential
60 N2 = [mNt3(:,i), sum(mNt3,2)-mNt3(:,i)];
61 Vt3 = [var(N2(:,1)), var(N2(:,2))];
62 dvt3(i) = Vt3(1)-Vt3(2);
66if strcmp(method,
'exact_delta') == 1
67 fit = m3pp2m_fitc(a, bt1, bt2, binf, m3t2, t1, t2, ai, dvt3, t3);
68elseif strcmp(method,
'approx_delta') == 1
69 fit = m3pp2m_fitc_approx(a, bt1, bt2, binf, m3t2, t1, t2, ai, dvt3, t3);
70elseif strcmp(method,
'approx_cov') == 1
72 vi = [var(mNt3(:,1)), var(mNt3(:,2))];
73 s = 0.5 * (V - sum(vi));
74 fit = m3pp22_fitc_approx_cov(a, bt1, bt2, binf, m3t2, t1, t2, ai, s, t3);
75elseif strcmp(method,
'approx_ag') == 1
79 covt3 = cov(mNt3(:,i), sum(mNt3,2)-mNt3(:,i));
83 fit = m3pp2m_fitc_approx_ag(a, bt1, bt2, binf, m3t2, t1, t2, ai, gt3, t3);
85 error('Invalid method
''%s\
''', method);