1% [alpha, A] = PH2From3Moments(moms, prec)
3% Returns a PH(2) which has the same 3 moments as given.
7% moms : vector of doubles, length(3)
9% prec :
double, optional
10% Numerical precision, default value
is 1e-14
14% alpha : matrix, shape (1,2)
15% The initial probability vector of the PH(2)
16% A : matrix, shape (2,2)
17% Transient generator matrix of the PH(2)
21% Raises an error if the moments are not feasible with
26% .. [1] M. Telek and A. Heindl, "Moment bounds for acyclic
27% discrete and continuous phase-type distributions of
28% second order," in In Proc. of UK Performance
29% Evaluation Workshop, UKPEW, 2002"
31function [alpha, A] = PH2From3Moments (moms, prec)
33 if ~exist('prec','var')
41 % check moment boounds
42 m2l = APH2ndMomentLowerBound(m1, 2);
43 m3l = APH3rdMomentLowerBound(m1, m2, 2);
44 m3u = APH3rdMomentUpperBound(m1, m2, 2);
47 error('The given second moment
is not feasible!');
50 error('The given third moment
is not feasible (too small)!');
53 error('The given third moment
is not feasible (too large)!');
56 % check if we have an exponential distribution
57 if abs(m2/m1/m1-2.0) < prec
63 % calculate parameters
65 c = 3.0*m2*m2-2.0*m1*m3;
73 lambda1 = (b - a) / c;
74 lambda2 = (b + a) / c;
75 p = (-b-6.0*m1*e+a) / (b+a);
77 lambda1 = (b + a) / c;
78 lambda2 = (b - a) / c;
79 p = (b+6.0*m1*e+a) / (-b+a);
88 A = [-lambda1, lambda1; 0,-lambda2];