1function [
MMAP,PHs] = mmap_mixture_fit(P2,M1,M2,M3)
2% Fits a
MMAP with m
classes using a mixture of m^2 PH-distributions.
3% Each PH distribution represents the probability distribution conditioned
4% on the fact that the last arrival was of
class i and the next arrival
is
5% of
class j. Currently, the PH distributions are of the second order,
6% hence the cross moments of order 1, 2 and 3 are required.
9% - P2: two-step
class transition probabilities (use mtrace_sigma2)
10% - M1: matrix of first-order cross moments
11% - M2: matrix of first-order cross moments
12% - M3: matrix of first-order cross moments
15% - PHs: the fitted PH-distributions
for each transition
23 % approximate fitting of second and third moments
25 PHs{i,j} = aph2_fit(m1, M2(i,j), M3(i,j));
26 % compare theoretical and fitted moments
27 % fprintf(
'PH{%d,%d}: M1 = %.3e, M2 = %.3e (%.3e), M3 = %.3e (%.3e)\n', i, j, m1, m2, M2(i,j), m3, M3(i,j));
32MMAP{1} = zeros(2*m^2, 2*m^2);
33MMAP{2} = zeros(2*m^2, 2*m^2);
35 MMAP{2+i} = zeros(2*m^2, 2*m^2);
42 MMAP{1}(first:last,first:last) = PHs{i,j}{1};
57 Q = (-PHs{i1,j1}{1}) * ones(2,1) * map_pie(PHs{i2,j2});
58 p = P2(i1,i2,j2)/sum(P2(i1,i2,:));
63 MMAP{2}(firstr:lastr,firstc:lastc) = p * Q;
64 MMAP{2+j1}(firstr:lastr,firstc:lastc) = p * Q;
82FM{1} = mmap_cross_moment(
MMAP,1);
83FM{2} = mmap_cross_moment(
MMAP,2);
84FM{3} = mmap_cross_moment(
MMAP,3);
88% %fprintf(
'MMAP CROSS(%d,%d): ', i, j);
90% % fprintf(
'M%d = %.3e (%.3e)', h, FM{h}(i,j), M{h}(i,j));
99FP2 = mmap_sigma2(
MMAP);
102% %fprintf(
'MMAP p(%d,%d,:): ', i, j);
104% % fprintf(
'p(%d,%d,%d) = %.3e (%.3e)', i, j, h, P2(i,j,h), FP2(i,j,h));