LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
mamap22_fit_gamma_fs.m
1function MMAP = mamap22_fit_gamma_fs(M1, M2, M3, GAMMA, P, F, S)
2% Performs approximate fitting of a MMAP given the underlying MAP,
3% the class probabilities (always fitted exactly), the forward moments,
4% and the one-step class transition probabilities.
5% Input
6% - M1,M2,M3: moments of the inter-arrival times
7% - GAMMA: auto-correlation decay rate of the inter-arrival times
8% - P: class probabilities
9% - F: first-order forward moments
10% - S: one-step class transition probabilities
11% Output
12% - mmap: fitted MAMAP[2]
13
14if size(F,1) == 1
15 F = F';
16end
17
18% fit underlying AMAP(2)
19[~,MAPS] = amap2_fit_gamma(M1, M2, M3, GAMMA);
20
21% TODO: if it is a Poisson process then use second-order Poisson process
22% with (h2 - h1 r2 = 0)
23
24% fit marked Poisson process
25if length(MAPS) == 1 && size(MAPS{1}{1},1) == 1
26 MAP = MAPS{1};
27 % number of classes
28 m = length(P);
29 % fit class probabilities
30 MMAP = cell(1,2+m);
31 MMAP{1} = MAP{1};
32 MMAP{2} = MAP{2};
33 for c = 1:m
34 MMAP{2+c} = MMAP{2} .* P(c);
35 end
36 return;
37end
38
39% fit the MAMAP(2,m) using the underlying AMAP(2) form which produces the
40% least error
41MMAPS = cell(1,length(MAPS));
42ERRORS = zeros(1,length(MAPS));
43for j = 1:length(MAPS)
44 [MMAPS{j},fF,fS] = mamap22_fit_fs_multiclass(MAPS{j}, P, F, S);
45 ERRORS(j) = sum((fF(1)./F(1) - 1).^2) + sum((fS(1,1)./S(1,1) - 1).^2);
46end
47[~,BEST] = min(ERRORS);
48
49MMAP = MMAPS{BEST};
50
51end