LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
aph2_fit.m
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
4% infeasible.
5% Input:
6% - M1,M2,M3: the first three moments
7% Output:
8% - APH: the fitted phase-type distributions
9% - APHS: all feasible forms of the fitted distribution
10
11
12% perform exact fitting
13APHS = aph2_fitall(M1, M2, M3);
14
15% if no solutions is found, perform approximate fitting
16if isempty(APHS)
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);
21 if isempty(APHS)
22 error('Fitting APH(2): feasibility could not be restored');
23 else
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);
27 end
28else
29% fprintf('Fitting APH(2): %d exact solutions\n', length(APHS));
30end
31
32APH = APHS{1};
33
34end