LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
maph2m_fit.m
1function MAPH = maph2m_fit(M1, M2, M3, P, B)
2% Computes the second-order MAPH[m] fitting the given ordinary moments
3% (of order up to three), the class probabilities (always fitted exactly)
4% and the backward moments,
5%
6% Input
7% - M1,M2,M3: moments of the inter-arrival times
8% - P: class probabilities
9% - B: first-order backward moments
10% Output
11% - MAPH: fitted second-order MAPH[m]
12
13if size(B,1) == 1
14 B = B';
15end
16
17% fit underlying AMAP(2)
18[~,APHS] = aph2_fit(M1, M2, M3);
19
20% fit the MAMAP(2,m) using the underlying AMAP(2) form which produces the
21% least error
22MAPHS = cell(1,length(APHS));
23ERRORS = zeros(1,length(APHS));
24for j = 1:length(APHS)
25 [MAPHS{j},fB] = maph2m_fit_multiclass(APHS{j}, P, B);
26 ERRORS(j) = sum((fB./B - 1).^2);
27end
28[~,BEST] = min(ERRORS);
29
30MAPH = MAPHS{BEST};
31
32end