1function [APH, APHS] = aph2_fit(M1, M2, M3)
2% Fits a second order phase-type distributions, given the first three
3% moments. Approximate fitting
is performed
if the given moments are
6% - M1,M2,M3: the first three moments
8% - APH: the fitted phase-type distributions
9% - APHS: all feasible forms of the fitted distribution
12% perform exact fitting
13APHS = aph2_fitall(M1, M2, M3);
15%
if no solutions
is found, perform approximate fitting
17 % find feasible characteristics
18 [M2a, M3a] = aph2_adjust(M1, M2, M3);
19 % fit (should found at least one solution)
20 APHS = aph2_fitall(M1, M2a, M3a);
22 error(
'Fitting APH(2): feasibility could not be restored');
24% fprintf(
'Fitting APH(2): %d approximate solutions\n', length(APHS));
25% fprintf(
'Fitting APH(2): M2 = %f -> %f\n', M2, M2a);
26% fprintf(
'Fitting APH(2): M3 = %f -> %f\n', M3, M3a);
29% fprintf(
'Fitting APH(2): %d exact solutions\n', length(APHS));