butools.ph.MonocyclicPHFromME

butools.ph.MonocyclicPHFromME()
Matlab: [beta, B] = MonocyclicPHFromME(alpha, A, maxSize, precision)
Mathematica: {beta, B} = MonocyclicPHFromME[alpha, A, maxSize, precision]
Python/Numpy: beta, B = MonocyclicPHFromME(alpha, A, maxSize, precision)

Transforms an arbitrary matrix-exponential representation to a Markovian monocyclic representation.

Parameters:

alpha : matrix, shape (1,N)

Initial vector of the distribution

A : matrix, shape (N,N)

Matrix parameter of the distribution

maxSize : int, optional

The maximum number of phases for the result. The default value is 100.

precision : double, optional

Vector and matrix entries smaller than the precision are considered to be zeros. The default value is 1e-14.

Returns:

beta : matrix, shape (1,M)

The initial probability vector of the Markovian monocyclic representation

B : matrix, shape (M,M)

Transient generator matrix of the Markovian monocyclic representation

Notes

Raises an error if no Markovian monocyclic representation has been found.

References

[R38]Mocanu, S., Commault, C.: “Sparse representations of phase-type distributions,” Stoch. Models 15, 759-778 (1999)

Examples

For Matlab:

>>> a = [0.2,0.3,0.5];
>>> A = [-1., 0., 0.; 0., -3., 2.; 0., -2., -3.];
>>> [b, B] = MonocyclicPHFromME(a, A);
>>> disp(b);
  Columns 1 through 6
  -8.1021e-17     0.010077     0.019799    0.0077544    0.0010922   4.0852e-05
  Columns 7 through 12
   1.3538e-05   0.00011267   0.00039486   0.00093038    0.0018049    0.0031208
  Columns 13 through 18
    0.0049985    0.0075762      0.01101     0.015473     0.021149     0.028228
  Columns 19 through 24
     0.036901     0.047341     0.059692     0.074045     0.090409      0.10868
  Columns 25 through 27
      0.12858      0.14965      0.17112
>>> disp(B);
  Columns 1 through 6
           -1            1            0            0            0            0
            0           -3            3            0            0            0
            0            0           -3            3            0            0
            0            0            0           -3            3            0
            0      0.59259            0            0           -3       2.4074
            0            0            0            0            0      -17.531
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
  Columns 7 through 12
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
       17.531            0            0            0            0            0
      -17.531       17.531            0            0            0            0
            0      -17.531       17.531            0            0            0
            0            0      -17.531       17.531            0            0
            0            0            0      -17.531       17.531            0
            0            0            0            0      -17.531       17.531
            0            0            0            0            0      -17.531
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
  Columns 13 through 18
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
       17.531            0            0            0            0            0
      -17.531       17.531            0            0            0            0
            0      -17.531       17.531            0            0            0
            0            0      -17.531       17.531            0            0
            0            0            0      -17.531       17.531            0
            0            0            0            0      -17.531       17.531
            0            0            0            0            0      -17.531
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
  Columns 19 through 24
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
       17.531            0            0            0            0            0
      -17.531       17.531            0            0            0            0
            0      -17.531       17.531            0            0            0
            0            0      -17.531       17.531            0            0
            0            0            0      -17.531       17.531            0
            0            0            0            0      -17.531       17.531
            0            0            0            0            0      -17.531
            0            0            0            0            0            0
            0            0            0            0            0            0
            0            0            0            0            0            0
  Columns 25 through 27
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
            0            0            0
       17.531            0            0
      -17.531       17.531            0
            0      -17.531       17.531
            0            0      -17.531
>>> ma = MomentsFromME(a, A, 5);
>>> disp(ma);
      0.35385      0.41893       1.1552       4.6998       23.838
>>> mb = MomentsFromME(b, B, 5);
>>> disp(mb);
      0.35385      0.41893       1.1552       4.6998       23.838

For Mathematica:

>>> a = {0.2,0.3,0.5};
>>> A = {{-1., 0., 0.},{0., -3., 2.},{0., -2., -3.}};
>>> {b, B} = MonocyclicPHFromME[a, A];
>>> Print[b];
{-2.5397600778722706*^-17, 0.010076564579360592, 0.019799026572787613, 0.007754395700638792, 0.0010921892175280797, 0.00004085157730567139, 0.000013537575173626456, 0.00011267376891308164, 0.0003948571244651649, 0.0009303831689188193, 0.001804898763447438, 0.003120837336642398, 0.004998456760755956, 0.007576247022797484, 0.01101041315944734, 0.01547306860911693, 0.02114869573602008, 0.028228345073631006, 0.036900955049397284, 0.04734108305260393, 0.059692251707772884, 0.07404503804493777, 0.09040897715773615, 0.10867732789998653, 0.1285837713807389, 0.1496502023195005, 0.1711249516403759}
>>> Print[B];
{{-1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., -3., 3., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., -3., 3., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., -3., 3., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0.5925925925925928, 0., 0., -3., 2.4074074074074074, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0., 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363, 0.},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363, 17.531049512315363},
 {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -17.531049512315363}}
>>> ma = MomentsFromME[a, A, 5];
>>> Print[ma];
{0.3538461538461538, 0.41893491124260357, 1.1552116522530724, 4.699835439935577, 23.837756165615836}
>>> mb = MomentsFromME[b, B, 5];
>>> Print[mb];
{0.3538461538461526, 0.4189349112425999, 1.1552116522530596, 4.69983543993552, 23.83775616561553}

For Python/Numpy:

>>> a = ml.matrix([[0.2,0.3,0.5]])
>>> A = ml.matrix([[-1., 0., 0.],[0., -3., 2.],[0., -2., -3.]])
>>> b, B = MonocyclicPHFromME(a, A)
>>> print(b)
[[ -4.29548e-17   1.00766e-02   1.97990e-02   7.75440e-03   1.09219e-03   4.08516e-05   1.35376e-05   1.12674e-04   3.94857e-04   9.30383e-04   1.80490e-03   3.12084e-03   4.99846e-03   7.57625e-03   1.10104e-02   1.54731e-02   2.11487e-02   2.82283e-02   3.69010e-02   4.73411e-02   5.96923e-02   7.40450e-02   9.04090e-02   1.08677e-01   1.28584e-01   1.49650e-01   1.71125e-01]]
>>> print(B)
[[ -1.        1.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.       -3.        3.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.       -3.        3.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.       -3.        3.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.59259   0.        0.       -3.        2.40741   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.        0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105   0.     ]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105  17.53105]
 [  0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.        0.      -17.53105]]
>>> ma = MomentsFromME(a, A, 5)
>>> print(ma)
[0.35384615384615381, 0.41893491124260357, 1.1552116522530724, 4.6998354399355771, 23.837756165615836]
>>> mb = MomentsFromME(b, B, 5)
>>> print(mb)
[0.35384615384615531, 0.41893491124260573, 1.155211652253076, 4.699835439935578, 23.83775616561579]