LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
mmap_mixture_order2.m
1function MMAP = mmap_mixture(PHs, P2)
2% Fits a MMAP with m classes using a mixture of m^2 PH-distributions.
3% PH{i,j} represents the IAT 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.
7%
8% INPUT
9% - PHs: PH distributions
10% - P2: two-step class transition probabilities
11% OUTPUT
12% - MMAP: the fitted MMAP
13% - PHs: the fitted PH-distributions for each transition
14
15% number of classes
16m = size(PHs,1);
17
18MMAP = cell(1,2+m);
19MMAP{1} = zeros(2*m^2, 2*m^2);
20MMAP{2} = zeros(2*m^2, 2*m^2);
21for i = 1:m
22 MMAP{2+i} = zeros(2*m^2, 2*m^2);
23end
24
25k = 1;
26for i = 1:m
27 for j = 1:m
28 first = (k-1)*2+1;
29 last = k*2;
30 MMAP{1}(first:last,first:last) = PHs{i,j}{1};
31 k = k + 1;
32 end
33end
34
35k1 = 1;
36for i1 = 1:m
37 for j1 = 1:m
38 k2 = 1;
39 for i2 = 1:m
40 for j2 = 1:m
41 firstr = (k1-1)*2+1;
42 lastr = k1*2;
43 firstc = (k2-1)*2+1;
44 lastc = k2*2;
45 if j1 == i2
46 Q = (-PHs{i1,j1}{1}) * ones(2,1) * map_pie(PHs{i2,j2});
47 p = P2(i1,i2);
48 else
49 Q = zeros(2,2);
50 p = 0;
51 end
52 MMAP{2}(firstr:lastr,firstc:lastc) = p * Q;
53 MMAP{2+j1}(firstr:lastr,firstc:lastc) = p * Q;
54 k2 = k2 + 1;
55 end
56 end
57 k1 = k1 +1;
58 end
59end
60
61% normalize diagonal
62for i = 1:(m^2)
63 MMAP{1}(i,i) = 0;
64end
65for i = 1:(m^2)
66 MMAP{1}(i,i) = -sum(MMAP{1}(i,1:end)+MMAP{2}(i,:));
67end
68
69
70end % end function