1% [alpha, A] = APHFrom2Moments(moms, maxSize)
3% Returns an acyclic PH which has the same 2 moments as
4% given. If detects the order and the structure
5% automatically to match the given moments.
9% moms : vector of doubles, length(2)
11% maxSize : int, optional
12% The maximal size of the resulting APH. The
default value
17% alpha : vector, shape (1,M)
18% The initial probability vector of the APH
19% A : matrix, shape (M,M)
20% Transient generator matrix of the APH
22% Raises an error
if the moments are not feasible with an
23% APH of size
"maxSize".
25function [alpha, A] = APHFrom2Moments (moms)
26 cv2 = moms(2)/moms(1)^2 - 1.0;
27 lambda = 1.0 / moms(1);
28 N = max(ceil(1.0/cv2), 2);
29 p = 1.0 / (cv2 + 1.0 + (cv2-1.0)/(N-1));
30 A = -lambda*p*N * eye(N);