1function
MMAP = mamap2m_fit_gamma_fb(M1, M2, M3, GAMMA,
P, F, B)
2% Computes the second-order MAMAP[m] fitting the given ordinary moments
3% (of order up to three), the autocorrelation decay rate,
4% the
class probabilities (always fitted exactly), the forward moments,
5% and the backward moments.
8% - M1,M2,M3: moments of the inter-arrival times
9% - GAMMA:
auto-correlation decay rate of the inter-arrival times
10% -
P:
class probabilities
11% - F: first-order forward moments
12% - B: first-order backward moments
14% - mmap: fitted MAMAP[m]
24% fit underlying AMAP(2)
25% up to four equivalent AMAP(2) representations may be found
26[~,MAPS] = amap2_fit_gamma(M1, M2, M3, GAMMA);
28% fit marked Poisson process
29if length(MAPS) == 1 && size(MAPS{1}{1},1) == 1
33 % fit
class probabilities
43% use the underlying AMAP(2) form which produces the least error
44MMAPS = cell(1,length(MAPS));
45ERRORS = zeros(1,length(MAPS));
47 [MMAPS{j},fF,fB] = mamap2m_fit_fb_multiclass(MAPS{j},
P, F, B);
48 ERRORS(j) = sum((fF./F - 1).^2) + sum((fB./B - 1).^2);
50[~,BEST] = min(ERRORS);
51%fprintf(
'Fitting MAMAP(2,m) F+B: minimum error is %e\n', ERRORS(BEST));