butools.queues.MAPMAP1

butools.queues.MAPMAP1()
Matlab: Ret = MAPMAP1(D0, D1, S0, S1, ...)
Mathematica: Ret = MAPMAP1[D0, D1, S0, S1, ...]
Python/Numpy: Ret = MAPMAP1(D0, D1, S0, S1, ...)

Returns various performane measures of a continuous time MAP/MAP/1 queue.

In a MAP/MAP/1 queue both the arrival and the service processes are characterized by Markovian arrival processes.

Parameters:

D0 : matrix, shape(N,N)

The transitions of the arrival MAP not accompanied by job arrivals

D1 : matrix, shape(N,N)

The transitions of the arrival MAP accompanied by job arrivals

S0 : matrix, shape(N,N)

The transitions of the service MAP not accompanied by job service

S1 : matrix, shape(N,N)

The transitions of the service MAP accompanied by job service

further parameters :

The rest of the function parameters specify the options and the performance measures to be computed.

The supported performance measures and options in this function are:

Parameter name Input parameters Output
“ncMoms” Number of moments The moments of the number of customers
“ncDistr” Upper limit K The distribution of the number of customers from level 0 to level K-1
“ncDistrMG” None The vector-matrix parameters of the matrix-geometric distribution of the number of customers in the system
“ncDistrDPH” None The vector-matrix parameters of the matrix-geometric distribution of the number of customers in the system, converted to a discrete PH representation
“stMoms” Number of moments The sojourn time moments
“stDistr” A vector of points The sojourn time distribution at the requested points (cummulative, cdf)
“stDistrME” None The vector-matrix parameters of the matrix-exponentially distributed sojourn time distribution
“stDistrPH” None The vector-matrix parameters of the matrix-exponentially distributed sojourn time distribution, converted to a continuous PH representation
“prec” The precision Numerical precision used as a stopping condition when solving the matrix-quadratic equation

(The quantities related to the number of customers in the system include the customer in the server, and the sojourn time related quantities include the service times as well)

Returns:

Ret : list of the performance measures

Each entry of the list corresponds to a performance measure requested. If there is just a single item, then it is not put into a list.

Notes

“ncDistrMG” and “stDistrME” behave much better numerically than “ncDistrDPH” and “stDistrPH”.

Examples

For Matlab:

>>> D0 = [-8., 1., 2.; 0., -6., 4.; 3., 0., -3.];
>>> D1 = [4., 1., 0.; 0., 2., 0.; 0., 0., 0.];
>>> S0 = [-10., 4.; 0., -7.];
>>> S1 = [5., 1.; 4., 3.];
>>> [ncd, ncm] = MAPMAP1(D0, D1, S0, S1, 'ncDistr', 11, 'ncMoms', 5);
>>> disp(ncd);
  Columns 1 through 8
      0.67697      0.18891      0.07951     0.032563     0.013182    0.0053087    0.0021328   0.00085583
  Columns 9 through 11
   0.00034322    0.0001376   5.5158e-05
>>> disp(ncm);
      0.54864        1.306        4.357       19.193       105.39
>>> [alphap, Ap] = MAPMAP1(D0, D1, S0, S1, 'ncDistrDPH');
>>> disp(alphap);
     0.067133     0.075328       0.0407     0.047054     0.035736     0.057079
>>> disp(Ap);
       0.2813     0.046292    0.0076126    0.0034456            0            0
      0.10552      0.33506    0.0083548      0.01223            0            0
      0.17544     0.045811      0.13666     0.010563            0            0
     0.079843      0.20353     0.042265      0.16552            0            0
      0.20818     0.091826      0.05939     0.013516            0            0
       0.1325      0.20874     0.034792     0.065764            0            0
>>> [alpha, A] = MAPMAP1(D0, D1, S0, S1, 'ncDistrMG');
>>> disp(alpha);
       0.1111     0.010481      0.10662     -0.80772      0.48646      0.41608
>>> disp(A);
      0.16291     0.023017       0.1119     -0.13707   -0.0046024      0.28152
     -0.06844      0.32235     -0.06034     0.037524     -0.15214      0.35383
    -0.060271       0.1733     0.035807     0.028632     -0.12729      0.35975
    -0.059415      0.16196     -0.10712      0.18069      -0.1826      0.39939
    -0.059415      0.16196     -0.10712      0.18069      -0.1826      0.39939
    -0.059415      0.16196     -0.10712      0.18069      -0.1826      0.39939
>>> ncdFromDPH = PmfFromDPH(alphap, Ap, (0:1:10));
>>> disp(ncdFromDPH);
  Columns 1 through 8
      0.67697      0.18891      0.07951     0.032563     0.013182    0.0053087    0.0021328   0.00085583
  Columns 9 through 11
   0.00034322    0.0001376   5.5158e-05
>>> ncmFromMG = MomentsFromMG(alpha, A, 5);
>>> disp(ncmFromMG);
      0.54864        1.306        4.357       19.193       105.39
>>> [std, stm] = MAPMAP1(D0, D1, S0, S1, 'stDistr', (0.:0.1:1.), 'stMoms', 5);
>>> disp(std);
  Columns 1 through 8
   1.1102e-16       0.3122      0.53197      0.68345      0.78667      0.85655      0.90367      0.93538
  Columns 9 through 11
      0.95667      0.97097      0.98055
>>> disp(stm);
      0.25908      0.13145      0.09911     0.099178      0.12376
>>> [betap, Bp] = MAPMAP1(D0, D1, S0, S1, 'stDistrPH');
>>> disp(betap);
      0.27119      0.39548      0.13559      0.19774
>>> disp(Bp);
      -8.1822       1.8689      0.12464      0.12862
       3.6856      -5.9854     0.047157     0.063652
       1.2252       1.2825      -9.0589      0.94899
      0.34891      0.66063       3.4502      -6.4625
>>> [beta, B] = MAPMAP1(D0, D1, S0, S1, 'stDistrME');
>>> disp(beta);
      0.40071      0.26596      0.19675      0.13659            0            0
>>> disp(B);
      -8.1822        4.607      0.61259      0.21807            0            0
       1.4951      -5.9854      0.51299      0.33032            0            0
      0.24927      0.11789      -9.0589       4.3127            0            0
      0.20579       0.1273      0.75919      -6.4625            0            0
       0.5575      0.23374      0.18872     0.080814          -10            4
      0.44853      0.30439       0.1539     0.099095            0           -7
>>> stdFromPH = CdfFromPH(betap, Bp, (0.:0.1:1.));
>>> disp(stdFromPH);
  Columns 1 through 8
            0       0.3122      0.53197      0.68345      0.78667      0.85655      0.90367      0.93538
  Columns 9 through 11
      0.95667      0.97097      0.98055
>>> stmFromME = MomentsFromME(beta, B, 5);
>>> disp(stmFromME);
      0.25908      0.13145      0.09911     0.099178      0.12376
>>> delta = [0.5,0.1,0.4];
>>> Dm = [-8., 1., 2.; 0., -6., 4.; 3., 0., -3.];
>>> sigma = [0.2,0.7,0.1];
>>> S = [-10., 4., 0.; 5., -7., 2.; 1., 2., -8.];
>>> D0 = Dm;
>>> D1 = sum(-Dm,2)*delta;
>>> S0 = S;
>>> S1 = sum(-S,2)*sigma;
>>> [ncd, ncm] = MAPMAP1(D0, D1, S0, S1, 'ncDistr', 11, 'ncMoms', 5);
>>> disp(ncd);
  Columns 1 through 8
      0.33826      0.21299       0.1455     0.098491     0.066529     0.044917     0.030323      0.02047
  Columns 9 through 11
     0.013818    0.0093279    0.0062968
>>> disp(ncm);
       2.0439       10.554       80.619       820.69        10443
>>> [alphap, Ap] = MAPMAP1(D0, D1, S0, S1, 'ncDistrDPH');
>>> disp(alphap);
  Columns 1 through 8
     0.074729      0.11816     0.037058     0.019693      0.03096    0.0097648      0.12199      0.18879
  Column 9
       0.0606
>>> disp(Ap);
  Columns 1 through 8
      0.26782      0.31102     0.050454     0.028231     0.032596     0.005318            0            0
      0.12042       0.4268     0.051941     0.012693      0.04473    0.0054746            0            0
     0.093612      0.29656      0.24254    0.0098678      0.03108     0.025565            0            0
      0.25805      0.31793     0.051505     0.027202      0.03332    0.0054287            0            0
      0.12382      0.42297     0.053367     0.013052     0.044328     0.005625            0            0
     0.095477      0.30306       0.2325     0.010064     0.031762     0.024506            0            0
      0.22985      0.33605     0.056865     0.024229     0.035219    0.0059937            0            0
      0.13243        0.412     0.058567      0.01396     0.043179    0.0061731            0            0
      0.10836      0.32375      0.19362     0.011422      0.03393     0.020408            0            0
  Column 9
            0
            0
            0
            0
            0
            0
            0
            0
            0
>>> [alpha, A] = MAPMAP1(D0, D1, S0, S1, 'ncDistrMG');
>>> disp(alpha);
  Columns 1 through 8
      0.33539      0.11124     -0.11565      0.22684     0.049774     -0.83292      -2.2177       2.6612
  Column 9
      0.44353
>>> disp(A);
  Columns 1 through 8
      0.23011      0.17196    -0.041192      0.15685      0.08314      -1.0418      -1.0077       1.5932
     0.092072      0.32509    -0.031637     0.067255      0.14976      -1.3362     -0.52827       1.4421
     0.093673      0.13219      0.17527     0.068436     0.063802      -1.1347     -0.53458       1.0089
       0.1138      0.13806      0.14334     0.081476     0.066654       -1.121     -0.60436       1.0951
     0.093316       0.1752      0.12914     0.068173     0.082966      -1.1796     -0.53317       1.1055
     0.093673      0.13219      0.17527     0.068436     0.063802      -1.1347     -0.53458       1.0089
     0.093673      0.13219      0.17527     0.068436     0.063802      -1.1347     -0.53458       1.0089
     0.093673      0.13219      0.17527     0.068436     0.063802      -1.1347     -0.53458       1.0089
     0.093673      0.13219      0.17527     0.068436     0.063802      -1.1347     -0.53458       1.0089
  Column 9
      0.53741
      0.49554
      0.79874
      0.76019
      0.73114
      0.79874
      0.79874
      0.79874
      0.79874
>>> ncdFromDPH = PmfFromDPH(alphap, Ap, (0:1:10));
>>> disp(ncdFromDPH);
  Columns 1 through 8
      0.33826      0.21299       0.1455     0.098491     0.066529     0.044917     0.030323      0.02047
  Columns 9 through 11
     0.013818    0.0093279    0.0062968
>>> ncmFromMG = MomentsFromMG(alpha, A, 5);
>>> disp(ncmFromMG);
       2.0439       10.554       80.619       820.69        10443
>>> [std, stm] = MAPMAP1(D0, D1, S0, S1, 'stDistr', (0.:0.1:1.), 'stMoms', 5);
>>> disp(std);
  Columns 1 through 8
   2.2204e-16     0.067321      0.14411      0.21822      0.28688      0.34979      0.40723      0.45962
  Columns 9 through 11
      0.50738      0.55093      0.59062
>>> disp(stm);
       1.1135       2.4113       7.8173       33.786       182.52
>>> [betap, Bp] = MAPMAP1(D0, D1, S0, S1, 'stDistrPH');
>>> disp(betap);
  Columns 1 through 8
      0.35369            0      0.14631     0.070739            0     0.029261      0.28295            0
  Column 9
      0.11705
>>> disp(Bp);
  Columns 1 through 8
      -9.7151       8.1485      0.63533     0.032747     0.049378     0.016146     0.087771      0.17848
       3.2004       -6.235      0.94726     0.073403      0.11068     0.036192      0.19674      0.40007
      0.28699        6.635        -7.86     0.032986     0.049738     0.016264     0.088411      0.17978
      0.28492      0.34127      0.13895      -9.9673       7.8566      0.51253     0.087771      0.17848
      0.63864      0.76496      0.31145       2.6351      -6.8893      0.67199      0.19674      0.40007
      0.28699      0.34375      0.13996     0.032986        6.341      -7.9837     0.088411      0.17978
      0.28492      0.34127      0.13895     0.032747     0.049378     0.016146      -9.9122       7.9857
      0.63864      0.76496      0.31145     0.073403      0.11068     0.036192       2.7585      -6.5999
      0.28699      0.34375      0.13996     0.032986     0.049738     0.016264     0.088411        6.471
  Column 9
     0.044593
     0.099956
     0.044918
     0.044593
     0.099956
     0.044918
      0.54098
      0.73576
      -7.9551
>>> [beta, B] = MAPMAP1(D0, D1, S0, S1, 'stDistrME');
>>> disp(beta);
  Columns 1 through 8
      0.14329      0.28553     0.071181     0.028658     0.057106     0.014236      0.11463      0.22842
  Column 9
     0.056945
>>> disp(B);
  Columns 1 through 8
      -9.7151       4.9972      0.14246     0.056983      0.19944     0.028492      0.22793      0.79777
       5.2186       -6.235       2.1093     0.043712      0.15299     0.021856      0.17485      0.61196
       1.2799       2.9797        -7.86     0.055984      0.19594     0.027992      0.22394      0.78377
      0.16374      0.57307     0.081868      -9.9673       4.1146     0.016374      0.13099      0.45846
      0.15812      0.55341     0.079058       5.0316      -6.8893       2.0158      0.12649      0.44273
      0.16264      0.56923     0.081319       1.0325       2.1138      -7.9837      0.13011      0.45539
      0.10971        0.384     0.054857     0.021943       0.0768     0.010971      -9.9122       4.3072
      0.14288      0.50009     0.071442     0.028577      0.10002     0.014288       5.1143      -6.5999
      0.11229      0.39303     0.056147     0.022459     0.078606     0.011229       1.0898       2.3144
  Column 9
      0.11397
     0.087423
      0.11197
     0.065494
     0.063247
     0.065055
     0.043886
       2.0572
      -7.9551
>>> stdFromPH = CdfFromPH(betap, Bp, (0.:0.1:1.));
>>> disp(stdFromPH);
  Columns 1 through 8
            0     0.067321      0.14411      0.21822      0.28688      0.34979      0.40723      0.45962
  Columns 9 through 11
      0.50738      0.55093      0.59062
>>> stmFromME = MomentsFromME(beta, B, 5);
>>> disp(stmFromME);
       1.1135       2.4113       7.8173       33.786       182.52

For Mathematica:

>>> D0 = {{-8., 1., 2.},{0., -6., 4.},{3., 0., -3.}};
>>> D1 = {{4., 1., 0.},{0., 2., 0.},{0., 0., 0.}};
>>> S0 = {{-10., 4.},{0., -7.}};
>>> S1 = {{5., 1.},{4., 3.}};
>>> {ncd, ncm} = MAPMAP1[D0, D1, S0, S1, "ncDistr", 11, "ncMoms", 5];
"Final Residual Error for G: "1.0408340855860843*^-16
"Final Residual Error for R: "1.3877787807814457*^-16
>>> Print[ncd];
{0.6769690927218346, 0.18890601544446484, 0.07950988455548241, 0.032562815367099616, 0.013182008065251377, 0.005308701544215693, 0.00213277061566337, 0.0008558335516777699, 0.0003432229641681273, 0.00013760305702500175, 0.00005515776673456938}
>>> Print[ncm];
{0.5486395318641362, 1.3060488095463447, 4.357004424902784, 19.19295358204142, 105.38633755592997}
>>> {alphap, Ap} = MAPMAP1[D0, D1, S0, S1, "ncDistrDPH"];
"Final Residual Error for G: "1.0408340855860843*^-16
"Final Residual Error for R: "1.3877787807814457*^-16
>>> Print[alphap];
{0.06713336638603387, 0.07532832075280335, 0.040700005311250634, 0.04705391014775885, 0.03573592042634463, 0.05707938425397416}
>>> Print[Ap];
{{0.28130240531969064, 0.04629222581204726, 0.007612641693714353, 0.003445567933621212, 0., 0.},
 {0.10551669990408467, 0.33506431281604, 0.008354813144417458, 0.012229921483571509, 0., 0.},
 {0.17544233493101746, 0.04581068687974456, 0.13665561446203264, 0.010562750164590453, 0., 0.},
 {0.07984336109470196, 0.20353241432916766, 0.042265324532051944, 0.16551629424385653, 0., 0.},
 {0.20817723425870532, 0.0918264144940291, 0.059390327559432174, 0.013516066113380536, 0., 0.},
 {0.13250054324765906, 0.2087351339587931, 0.034792155582504015, 0.0657638702586556, 0., 0.}}
>>> {alpha, A} = MAPMAP1[D0, D1, S0, S1, "ncDistrMG"];
"Final Residual Error for G: "1.0408340855860843*^-16
"Final Residual Error for R: "1.3877787807814457*^-16
>>> Print[alpha];
{0.11109802951004608, 0.010480702136161618, 0.10662329054401752, -0.8077182308946177, 0.48646319457458154, 0.41608392140797645}
>>> Print[A];
{{0.1629053064844125, 0.023017401892469813, 0.11189525710750912, -0.13707103216123398, -0.00460237048747536, 0.2815167630916619},
 {-0.06843965017167865, 0.3223468624823151, -0.060340481045871086, 0.03752370826293791, -0.15213536522543497, 0.35382777946490074},
 {-0.060271277810733125, 0.17329866481605158, 0.03580746865942097, 0.02863218049808125, -0.12729406912309077, 0.35975047082003087},
 {-0.05941546558542623, 0.1619589748583506, -0.10712188703259878, 0.18068938099433576, -0.18260444681358848, 0.3993940550347238},
 {-0.05941546558542623, 0.1619589748583506, -0.10712188703259878, 0.18068938099433576, -0.18260444681358848, 0.3993940550347238},
 {-0.05941546558542623, 0.1619589748583506, -0.10712188703259878, 0.18068938099433576, -0.18260444681358848, 0.3993940550347238}}
>>> ncdFromDPH = PmfFromDPH[alphap, Ap, Range[0,10,1]];
>>> Print[ncdFromDPH];
{0.6769690927218345, 0.18890601544446484, 0.0795098845554824, 0.03256281536709962, 0.01318200806525138, 0.005308701544215695, 0.0021327706156633714, 0.0008558335516777703, 0.00034322296416812746, 0.0001376030570250018, 0.000055157766734569404}
>>> ncmFromMG = MomentsFromMG[alpha, A, 5];
>>> Print[ncmFromMG];
{0.5486395318641364, 1.3060488095463452, 4.357004424902785, 19.192953582041415, 105.38633755592993}
>>> {std, stm} = MAPMAP1[D0, D1, S0, S1, "stDistr", Range[0.,1.,0.1], "stMoms", 5];
"Final Residual Error for G: "1.0408340855860843*^-16
"Final Residual Error for R: "1.3877787807814457*^-16
>>> Print[std];
{1.1102230246251565*^-16, 0.31220200485532823, 0.5319693886055359, 0.683448492874903, 0.786668497914873, 0.8565469353128969, 0.9036716256123, 0.9353763920782243, 0.9566744696604379, 0.9709671432122016, 0.9805517895663979}
>>> Print[stm];
{0.25907977893584216, 0.1314530565761404, 0.09910977975365252, 0.0991778409591816, 0.12375826425492883}
>>> {betap, Bp} = MAPMAP1[D0, D1, S0, S1, "stDistrPH"];
"Final Residual Error for G: "1.0408340855860843*^-16
"Final Residual Error for R: "1.3877787807814457*^-16
>>> Print[betap];
{0.27118644067796616, 0.39548022598870064, 0.13559322033898305, 0.1977401129943503}
>>> Print[Bp];
{{-8.18221808955257, 1.868862984211661, 0.12463702298427055, 0.12861844665139152},
 {3.6856163463839864, -5.985377122566605, 0.04715723015286752, 0.06365232793573995},
 {1.2251890316565601, 1.282470479592513, -9.058949015866476, 0.9489932799691041},
 {0.3489096698540739, 0.6606305461695843, 3.450175746844795, -6.4624885396327}}
>>> {beta, B} = MAPMAP1[D0, D1, S0, S1, "stDistrME"];
"Final Residual Error for G: "1.0408340855860843*^-16
"Final Residual Error for R: "1.3877787807814457*^-16
>>> Print[beta];
{0.4007102782337436, 0.26595638843292296, 0.19674632576397322, 0.13658700756936012, 0., 0.}
>>> Print[B];
{{-8.18221808955257, 4.607020432979983, 0.61259451582828, 0.21806854365879616, 0., 0.},
 {1.4950903873693289, -5.985377122566605, 0.5129881918370052, 0.3303152730847921, 0., 0.},
 {0.24927404596854114, 0.11789307538216881, -9.058949015866476, 4.3127196835559936, 0., 0.},
 {0.20578951464222647, 0.12730465587147993, 0.7591946239752834, -6.4624885396327, 0., 0.},
 {0.5574964766296526, 0.23373913475846325, 0.18872072136071122, 0.08081415066754914, -10., 4.},
 {0.44852711621079855, 0.30438686323001857, 0.15389645755110154, 0.0990945819254376, 0., -7.}}
>>> stdFromPH = CdfFromPH[betap, Bp, Range[0.,1.,0.1]];
>>> Print[stdFromPH];
{0., 0.3122020048553279, 0.5319693886055358, 0.6834484928749028, 0.786668497914873, 0.856546935312897, 0.9036716256123, 0.9353763920782242, 0.9566744696604379, 0.9709671432122016, 0.9805517895663979}
>>> stmFromME = MomentsFromME[beta, B, 5];
>>> Print[stmFromME];
{0.25907977893584216, 0.1314530565761404, 0.09910977975365252, 0.0991778409591816, 0.12375826425492883}
>>> delta = {0.5,0.1,0.4};
>>> Dm = {{-8., 1., 2.},{0., -6., 4.},{3., 0., -3.}};
>>> sigma = {0.2,0.7,0.1};
>>> S = {{-10., 4., 0.},{5., -7., 2.},{1., 2., -8.}};
>>> D0 = Dm;
>>> D1 = Transpose[{Total[-Dm,{2}]}].{delta};
>>> S0 = S;
>>> S1 = Transpose[{Total[-S,{2}]}].{sigma};
>>> {ncd, ncm} = MAPMAP1[D0, D1, S0, S1, "ncDistr", 11, "ncMoms", 5];
"Final Residual Error for G: "2.8796409701215*^-16
"Final Residual Error for R: "2.5673907444456745*^-16
>>> Print[ncd];
{0.3382583000173821, 0.21298529276749126, 0.1455036749660385, 0.09849079999116112, 0.06652869034717646, 0.044917143499797356, 0.030322557234957335, 0.020469519523922355, 0.013818043581100023, 0.009327918288020327, 0.006296840863138073}
>>> Print[ncm];
{2.043920190427152, 10.553791196138821, 80.61928537723435, 820.6894786219923, 10442.52887895297}
>>> {alphap, Ap} = MAPMAP1[D0, D1, S0, S1, "ncDistrDPH"];
"Final Residual Error for G: "2.8796409701215*^-16
"Final Residual Error for R: "2.5673907444456745*^-16
>>> Print[alphap];
{0.0747292656813806, 0.1181643446209385, 0.03705768376723692, 0.019693372356747885, 0.030959986518879018, 0.009764840891516689, 0.12198619213743217, 0.1887863241704555, 0.060599689838030685}
>>> Print[Ap];
{{0.26781773085286764, 0.31101976305978485, 0.05045448201370804, 0.028231158164525778, 0.03259584844252456, 0.005317979312709587, 0., 0., 0.},
 {0.1204151193930397, 0.426803260037457, 0.051940881424856866, 0.012693178566480858, 0.04473032273605763, 0.0054746480763838545, 0., 0., 0.},
 {0.09361178537818889, 0.29655828531121786, 0.24254481404417771, 0.009867789972901992, 0.031080240134197804, 0.025564593114670967, 0., 0., 0.},
 {0.25805347211788343, 0.3179330582067931, 0.05150455357229029, 0.027201889744437005, 0.03332038349661052, 0.005428658455622758, 0., 0., 0.},
 {0.12382168736754393, 0.4229664164893307, 0.05336708312117147, 0.013052271144034176, 0.04432820947623766, 0.005624971909154385, 0., 0., 0.},
 {0.095476911834167, 0.3030612398902468, 0.23250227823873204, 0.010064396373112615, 0.03176177020740381, 0.024506094532800775, 0., 0., 0.},
 {0.22985295491631016, 0.33604933463865083, 0.05686493792626865, 0.024229221508828593, 0.03521902619090838, 0.005993651137440084, 0., 0., 0.},
 {0.13242835135132583, 0.41200326098416273, 0.05856727781254947, 0.01395951537846673, 0.04317923633130734, 0.006173080356354317, 0., 0., 0.},
 {0.10835583923850761, 0.32374817692321156, 0.19362199117845982, 0.011421987729680155, 0.03392982621012461, 0.020408053010888768, 0., 0., 0.}}
>>> {alpha, A} = MAPMAP1[D0, D1, S0, S1, "ncDistrMG"];
"Final Residual Error for G: "2.8796409701215*^-16
"Final Residual Error for R: "2.5673907444456745*^-16
>>> Print[alpha];
{0.335388097798228, 0.11124374834176529, -0.11565482233389898, 0.22684247560717574, 0.049774394541475475, -0.8329212637990596, -2.217672674567333, 2.661207209480798, 0.4435345349134663}
>>> Print[A];
{{0.23010874461138647, 0.17196369830044164, -0.04119187617645898, 0.1568451647402447, 0.08314023718352927, -1.0418469110562227, -1.0076930929970267, 1.5931894863967555, 0.5374143415183332},
 {0.09207203502871297, 0.3250868076906807, -0.031637329628947004, 0.06725527006540137, 0.1497556640191295, -1.3361636344419388, -0.5282671320547201, 1.4421155298051003, 0.49554465753990445},
 {0.09367269488934829, 0.1321911062922013, 0.17526524304297714, 0.06843629532664251, 0.06380192761345282, -1.1347373274317223, -0.5345801680271869, 1.0088804369648803, 0.798736724637723},
 {0.11379592294037874, 0.13805724607558675, 0.14333954611613192, 0.08147589772328324, 0.06665417388115764, -1.1210367326381352, -0.6043605472044968, 1.0950613567287801, 0.760193759482519},
 {0.09331582169637492, 0.17519793526434796, 0.12913552894210745, 0.06817298126078337, 0.08296563947595605, -1.1796460873121937, -0.533172652689134, 1.1054718457284263, 0.7311389021831358},
 {0.09367269488934832, 0.1321911062922014, 0.17526524304297716, 0.06843629532664249, 0.06380192761345285, -1.1347373274317225, -0.5345801680271869, 1.0088804369648805, 0.798736724637723},
 {0.09367269488934832, 0.1321911062922014, 0.17526524304297716, 0.06843629532664249, 0.06380192761345285, -1.1347373274317225, -0.5345801680271869, 1.0088804369648805, 0.798736724637723},
 {0.09367269488934832, 0.1321911062922014, 0.17526524304297716, 0.06843629532664249, 0.06380192761345285, -1.1347373274317225, -0.5345801680271869, 1.0088804369648805, 0.798736724637723},
 {0.09367269488934832, 0.1321911062922014, 0.17526524304297716, 0.06843629532664249, 0.06380192761345285, -1.1347373274317225, -0.5345801680271869, 1.0088804369648805, 0.798736724637723}}
>>> ncdFromDPH = PmfFromDPH[alphap, Ap, Range[0,10,1]];
>>> Print[ncdFromDPH];
{0.3382583000173821, 0.21298529276749126, 0.1455036749660385, 0.09849079999116114, 0.06652869034717646, 0.044917143499797356, 0.030322557234957335, 0.02046951952392236, 0.013818043581100023, 0.009327918288020327, 0.006296840863138071}
>>> ncmFromMG = MomentsFromMG[alpha, A, 5];
>>> Print[ncmFromMG];
{2.0439201904271664, 10.553791196138974, 80.61928537723583, 820.6894786220133, 10442.528878953299}
>>> {std, stm} = MAPMAP1[D0, D1, S0, S1, "stDistr", Range[0.,1.,0.1], "stMoms", 5];
"Final Residual Error for G: "2.8796409701215*^-16
"Final Residual Error for R: "2.5673907444456745*^-16
>>> Print[std];
{-2.220446049250313*^-16, 0.06732092429975123, 0.14410990918817657, 0.21821569553423958, 0.2868837551361466, 0.34979180437976287, 0.4072286119979047, 0.45961534708806473, 0.5073799327606132, 0.5509251846596359, 0.590622172200536}
>>> Print[stm];
{1.1135106870764584, 2.411324091748759, 7.8172702796512095, 33.78557510760976, 182.52100725089815}
>>> {betap, Bp} = MAPMAP1[D0, D1, S0, S1, "stDistrPH"];
"Final Residual Error for G: "2.8796409701215*^-16
"Final Residual Error for R: "2.5673907444456745*^-16
>>> Print[betap];
{0.35369318181818193, 0., 0.14630681818181818, 0.07073863636363638, 0., 0.029261363636363637, 0.2829545454545455, 0., 0.11704545454545455}
>>> Print[Bp];
{{-9.715083156753732, 8.148496507481427, 0.6353335255307762, 0.03274706510215011, 0.049378103925532595, 0.01614619488986971, 0.08777139112801251, 0.17848405075047077, 0.044593109982684585},
 {3.2003730166901305, -6.235044479758062, 0.9472560892491555, 0.07340295071122381, 0.11068162955530263, 0.03619189518138234, 0.19674065681086136, 0.4000742032639796, 0.09995600655840951},
 {0.28699148045437195, 6.635014685933965, -7.860040259477494, 0.03298551460532111, 0.04973765322596125, 0.016263764270135758, 0.08841050319933302, 0.17978369189671212, 0.04491781709420901},
 {0.284916843246268, 0.3412675918187785, 0.1389479833621017, -9.96725293489785, 7.856607019588182, 0.5125317370585444, 0.08777139112801254, 0.17848405075047077, 0.044593109982684585},
 {0.6386446216284014, 0.7649555202419378, 0.31145362011335304, 2.6351313457729524, -6.889318370444697, 0.6719943643171847, 0.19674065681086134, 0.4000742032639796, 0.09995600655840951},
 {0.28699148045437195, 0.3437525500116338, 0.1399597405225054, 0.03298551460532111, 6.3409997891482925, -7.983736235729865, 0.08841050319933302, 0.1797836918967121, 0.04491781709420901},
 {0.284916843246268, 0.3412675918187785, 0.1389479833621017, 0.032747065102150114, 0.0493781039255326, 0.016146194889869712, -9.912228608871988, 7.98571296641312, 0.5409786521513593},
 {0.6386446216284014, 0.7649555202419378, 0.31145362011335304, 0.07340295071122381, 0.1106816295553026, 0.03619189518138234, 2.75846905187259, -6.59992579673602, 0.7357584756942119},
 {0.28699148045437195, 0.3437525500116338, 0.1399597405225054, 0.03298551460532111, 0.049737653225961256, 0.016263764270135758, 0.08841050319933302, 6.471045827819043, -7.955082182905792}}
>>> {beta, B} = MAPMAP1[D0, D1, S0, S1, "stDistrME"];
"Final Residual Error for G: "2.8796409701215*^-16
"Final Residual Error for R: "2.5673907444456745*^-16
>>> Print[beta];
{0.14328764742307518, 0.28553117573889425, 0.07118117683803069, 0.028657529484615033, 0.057106235147778836, 0.01423623536760614, 0.11463011793846013, 0.22842494059111534, 0.056944941470424545}
>>> Print[B];
{{-9.715083156753732, 4.997208951361937, 0.14245842162313396, 0.05698336864925359, 0.1994417902723875, 0.028491684324626794, 0.22793347459701435, 0.79776716108955, 0.11396673729850718},
 {5.218558720069125, -6.235044479758062, 2.1092793600345625, 0.043711744013825035, 0.15299110404838756, 0.021855872006912518, 0.17484697605530014, 0.6119644161935502, 0.08742348802765007},
 {1.2799194810450107, 2.9797181836575377, -7.860040259477494, 0.05598389620900216, 0.19594363673150755, 0.02799194810450108, 0.22393558483600864, 0.7837745469260302, 0.11196779241800432},
 {0.1637353255107505, 0.5730736392876267, 0.08186766275537526, -9.96725293489785, 4.114614727857525, 0.016373532551075053, 0.13098826040860043, 0.45845891143010137, 0.06549413020430021},
 {0.15811661365043234, 0.5534081477765131, 0.07905830682521617, 5.031623322730087, -6.889318370444697, 2.0158116613650434, 0.1264932909203459, 0.44272651822121045, 0.06324664546017295},
 {0.16263764270135755, 0.5692317494547514, 0.08131882135067878, 1.0325275285402715, 2.11384634989095, -7.9837362357298645, 0.13011011416108606, 0.4553853995638012, 0.06505505708054303},
 {0.10971423891001564, 0.3839998361850546, 0.05485711945500782, 0.02194284778200313, 0.07679996723701092, 0.010971423891001565, -9.912228608871988, 4.307199868948044, 0.04388569556400626},
 {0.1428836440228499, 0.5000927540799744, 0.07144182201142495, 0.028576728804569976, 0.1000185508159949, 0.014288364402284988, 5.11430691521828, -6.59992579673602, 2.05715345760914},
 {0.1122945427355225, 0.3930308995743287, 0.05614727136776125, 0.0224589085471045, 0.07860617991486574, 0.01122945427355225, 1.0898356341884181, 2.314424719659463, -7.955082182905791}}
>>> stdFromPH = CdfFromPH[betap, Bp, Range[0.,1.,0.1]];
>>> Print[stdFromPH];
{-2.220446049250313*^-16, 0.06732092429975112, 0.14410990918817634, 0.2182156955342397, 0.2868837551361467, 0.3497918043797634, 0.4072286119979047, 0.4596153470880646, 0.5073799327606132, 0.5509251846596357, 0.5906221722005369}
>>> stmFromME = MomentsFromME[beta, B, 5];
>>> Print[stmFromME];
{1.1135106870764584, 2.411324091748759, 7.8172702796512095, 33.78557510760976, 182.52100725089815}

For Python/Numpy:

>>> D0 = ml.matrix([[-8., 1., 2.],[0., -6., 4.],[3., 0., -3.]])
>>> D1 = ml.matrix([[4., 1., 0.],[0., 2., 0.],[0., 0., 0.]])
>>> S0 = ml.matrix([[-10., 4.],[0., -7.]])
>>> S1 = ml.matrix([[5., 1.],[4., 3.]])
>>> ncd, ncm = MAPMAP1(D0, D1, S0, S1, "ncDistr", 11, "ncMoms", 5)
Final Residual Error for G:  2.35922392733e-16
Final Residual Error for R:  1.31838984174e-16
>>> print(ncd)
[  6.76969e-01   1.88906e-01   7.95099e-02   3.25628e-02   1.31820e-02   5.30870e-03   2.13277e-03   8.55834e-04   3.43223e-04   1.37603e-04   5.51578e-05]
>>> print(ncm)
[0.54863953186413617, 1.3060488095463447, 4.3570044249027839, 19.192953582041419, 105.38633755592997]
>>> alphap, Ap = MAPMAP1(D0, D1, S0, S1, "ncDistrDPH")
Final Residual Error for G:  2.35922392733e-16
Final Residual Error for R:  1.31838984174e-16
>>> print(alphap)
[[ 0.06713  0.07533  0.0407   0.04705  0.03574  0.05708]]
>>> print(Ap)
[[ 0.2813   0.04629  0.00761  0.00345  0.       0.     ]
 [ 0.10552  0.33506  0.00835  0.01223  0.       0.     ]
 [ 0.17544  0.04581  0.13666  0.01056  0.       0.     ]
 [ 0.07984  0.20353  0.04227  0.16552  0.       0.     ]
 [ 0.20818  0.09183  0.05939  0.01352  0.       0.     ]
 [ 0.1325   0.20874  0.03479  0.06576  0.       0.     ]]
>>> alpha, A = MAPMAP1(D0, D1, S0, S1, "ncDistrMG")
Final Residual Error for G:  2.35922392733e-16
Final Residual Error for R:  1.31838984174e-16
>>> print(alpha)
[[ 0.1111   0.01048  0.10662 -0.80772  0.48646  0.41608]]
>>> print(A)
[[ 0.16291  0.02302  0.1119  -0.13707 -0.0046   0.28152]
 [-0.06844  0.32235 -0.06034  0.03752 -0.15214  0.35383]
 [-0.06027  0.1733   0.03581  0.02863 -0.12729  0.35975]
 [-0.05942  0.16196 -0.10712  0.18069 -0.1826   0.39939]
 [-0.05942  0.16196 -0.10712  0.18069 -0.1826   0.39939]
 [-0.05942  0.16196 -0.10712  0.18069 -0.1826   0.39939]]
>>> ncdFromDPH = PmfFromDPH(alphap, Ap, np.arange(0,11.0,1))
>>> print(ncdFromDPH)
[  6.76969e-01   1.88906e-01   7.95099e-02   3.25628e-02   1.31820e-02   5.30870e-03   2.13277e-03   8.55834e-04   3.43223e-04   1.37603e-04   5.51578e-05]
>>> ncmFromMG = MomentsFromMG(alpha, A, 5)
>>> print(ncmFromMG)
[0.54863953186413594, 1.3060488095463438, 4.3570044249027813, 19.192953582041405, 105.38633755592987]
>>> std, stm = MAPMAP1(D0, D1, S0, S1, "stDistr", np.arange(0.,1.1,0.1), "stMoms", 5)
Final Residual Error for G:  2.35922392733e-16
Final Residual Error for R:  1.31838984174e-16
>>> print(std)
[  1.11022e-16   3.12202e-01   5.31969e-01   6.83448e-01   7.86668e-01   8.56547e-01   9.03672e-01   9.35376e-01   9.56674e-01   9.70967e-01   9.80552e-01]
>>> print(stm)
[0.25907977893584216, 0.1314530565761404, 0.099109779753652538, 0.099177840959181612, 0.12375826425492886]
>>> betap, Bp = MAPMAP1(D0, D1, S0, S1, "stDistrPH")
Final Residual Error for G:  2.35922392733e-16
Final Residual Error for R:  1.31838984174e-16
>>> print(betap)
[[ 0.27119  0.39548  0.13559  0.19774]]
>>> print(Bp)
[[-8.18222  1.86886  0.12464  0.12862]
 [ 3.68562 -5.98538  0.04716  0.06365]
 [ 1.22519  1.28247 -9.05895  0.94899]
 [ 0.34891  0.66063  3.45018 -6.46249]]
>>> beta, B = MAPMAP1(D0, D1, S0, S1, "stDistrME")
Final Residual Error for G:  2.35922392733e-16
Final Residual Error for R:  1.31838984174e-16
>>> print(beta)
[[ 0.40071  0.26596  0.19675  0.13659  0.       0.     ]]
>>> print(B)
[[ -8.18222   4.60702   0.61259   0.21807   0.        0.     ]
 [  1.49509  -5.98538   0.51299   0.33032   0.        0.     ]
 [  0.24927   0.11789  -9.05895   4.31272   0.        0.     ]
 [  0.20579   0.1273    0.75919  -6.46249   0.        0.     ]
 [  0.5575    0.23374   0.18872   0.08081 -10.        4.     ]
 [  0.44853   0.30439   0.1539    0.09909   0.       -7.     ]]
>>> stdFromPH = CdfFromPH(betap, Bp, np.arange(0.,1.1,0.1))
>>> print(stdFromPH)
[ 0.       0.3122   0.53197  0.68345  0.78667  0.85655  0.90367  0.93538  0.95667  0.97097  0.98055]
>>> stmFromME = MomentsFromME(beta, B, 5)
>>> print(stmFromME)
[0.25907977893584216, 0.1314530565761404, 0.099109779753652524, 0.099177840959181612, 0.12375826425492886]
>>> delta = ml.matrix([[0.5,0.1,0.4]])
>>> Dm = ml.matrix([[-8., 1., 2.],[0., -6., 4.],[3., 0., -3.]])
>>> sigma = ml.matrix([[0.2,0.7,0.1]])
>>> S = ml.matrix([[-10., 4., 0.],[5., -7., 2.],[1., 2., -8.]])
>>> D0 = Dm
>>> D1 = np.sum(-Dm,1)*delta
>>> S0 = S
>>> S1 = np.sum(-S,1)*sigma
>>> ncd, ncm = MAPMAP1(D0, D1, S0, S1, "ncDistr", 11, "ncMoms", 5)
Final Residual Error for G:  1.80411241502e-16
Final Residual Error for R:  4.02455846427e-16
>>> print(ncd)
[ 0.33826  0.21299  0.1455   0.09849  0.06653  0.04492  0.03032  0.02047  0.01382  0.00933  0.0063 ]
>>> print(ncm)
[2.0439201904271491, 10.553791196138791, 80.619285377234021, 820.68947862198797, 10442.5288789529]
>>> alphap, Ap = MAPMAP1(D0, D1, S0, S1, "ncDistrDPH")
Final Residual Error for G:  1.80411241502e-16
Final Residual Error for R:  4.02455846427e-16
>>> print(alphap)
[[ 0.07473  0.11816  0.03706  0.01969  0.03096  0.00976  0.12199  0.18879  0.0606 ]]
>>> print(Ap)
[[ 0.26782  0.31102  0.05045  0.02823  0.0326   0.00532  0.       0.       0.     ]
 [ 0.12042  0.4268   0.05194  0.01269  0.04473  0.00547  0.       0.       0.     ]
 [ 0.09361  0.29656  0.24254  0.00987  0.03108  0.02556  0.       0.       0.     ]
 [ 0.25805  0.31793  0.0515   0.0272   0.03332  0.00543  0.       0.       0.     ]
 [ 0.12382  0.42297  0.05337  0.01305  0.04433  0.00562  0.       0.       0.     ]
 [ 0.09548  0.30306  0.2325   0.01006  0.03176  0.02451  0.       0.       0.     ]
 [ 0.22985  0.33605  0.05686  0.02423  0.03522  0.00599  0.       0.       0.     ]
 [ 0.13243  0.412    0.05857  0.01396  0.04318  0.00617  0.       0.       0.     ]
 [ 0.10836  0.32375  0.19362  0.01142  0.03393  0.02041  0.       0.       0.     ]]
>>> alpha, A = MAPMAP1(D0, D1, S0, S1, "ncDistrMG")
Final Residual Error for G:  1.80411241502e-16
Final Residual Error for R:  4.02455846427e-16
>>> print(alpha)
[[ 0.33539  0.11124 -0.11565  0.22684  0.04977 -0.83292 -2.21767  2.66121  0.44353]]
>>> print(A)
[[ 0.23011  0.17196 -0.04119  0.15685  0.08314 -1.04185 -1.00769  1.59319  0.53741]
 [ 0.09207  0.32509 -0.03164  0.06726  0.14976 -1.33616 -0.52827  1.44212  0.49554]
 [ 0.09367  0.13219  0.17527  0.06844  0.0638  -1.13474 -0.53458  1.00888  0.79874]
 [ 0.1138   0.13806  0.14334  0.08148  0.06665 -1.12104 -0.60436  1.09506  0.76019]
 [ 0.09332  0.1752   0.12914  0.06817  0.08297 -1.17965 -0.53317  1.10547  0.73114]
 [ 0.09367  0.13219  0.17527  0.06844  0.0638  -1.13474 -0.53458  1.00888  0.79874]
 [ 0.09367  0.13219  0.17527  0.06844  0.0638  -1.13474 -0.53458  1.00888  0.79874]
 [ 0.09367  0.13219  0.17527  0.06844  0.0638  -1.13474 -0.53458  1.00888  0.79874]
 [ 0.09367  0.13219  0.17527  0.06844  0.0638  -1.13474 -0.53458  1.00888  0.79874]]
>>> ncdFromDPH = PmfFromDPH(alphap, Ap, np.arange(0,11.0,1))
>>> print(ncdFromDPH)
[ 0.33826  0.21299  0.1455   0.09849  0.06653  0.04492  0.03032  0.02047  0.01382  0.00933  0.0063 ]
>>> ncmFromMG = MomentsFromMG(alpha, A, 5)
>>> print(ncmFromMG)
[2.0439201904271451, 10.553791196138775, 80.61928537723395, 820.6894786219882, 10442.528878952886]
>>> std, stm = MAPMAP1(D0, D1, S0, S1, "stDistr", np.arange(0.,1.1,0.1), "stMoms", 5)
Final Residual Error for G:  1.80411241502e-16
Final Residual Error for R:  4.02455846427e-16
>>> print(std)
[ 0.       0.06732  0.14411  0.21822  0.28688  0.34979  0.40723  0.45962  0.50738  0.55093  0.59062]
>>> print(stm)
[1.1135106870764573, 2.411324091748754, 7.817270279651181, 33.785575107609588, 182.52100725089704]
>>> betap, Bp = MAPMAP1(D0, D1, S0, S1, "stDistrPH")
Final Residual Error for G:  1.80411241502e-16
Final Residual Error for R:  4.02455846427e-16
>>> print(betap)
[[ 0.35369  0.       0.14631  0.07074  0.       0.02926  0.28295  0.       0.11705]]
>>> print(Bp)
[[-9.71508  8.1485   0.63533  0.03275  0.04938  0.01615  0.08777  0.17848  0.04459]
 [ 3.20037 -6.23504  0.94726  0.0734   0.11068  0.03619  0.19674  0.40007  0.09996]
 [ 0.28699  6.63501 -7.86004  0.03299  0.04974  0.01626  0.08841  0.17978  0.04492]
 [ 0.28492  0.34127  0.13895 -9.96725  7.85661  0.51253  0.08777  0.17848  0.04459]
 [ 0.63864  0.76496  0.31145  2.63513 -6.88932  0.67199  0.19674  0.40007  0.09996]
 [ 0.28699  0.34375  0.13996  0.03299  6.341   -7.98374  0.08841  0.17978  0.04492]
 [ 0.28492  0.34127  0.13895  0.03275  0.04938  0.01615 -9.91223  7.98571  0.54098]
 [ 0.63864  0.76496  0.31145  0.0734   0.11068  0.03619  2.75847 -6.59993  0.73576]
 [ 0.28699  0.34375  0.13996  0.03299  0.04974  0.01626  0.08841  6.47105 -7.95508]]
>>> beta, B = MAPMAP1(D0, D1, S0, S1, "stDistrME")
Final Residual Error for G:  1.80411241502e-16
Final Residual Error for R:  4.02455846427e-16
>>> print(beta)
[[ 0.14329  0.28553  0.07118  0.02866  0.05711  0.01424  0.11463  0.22842  0.05694]]
>>> print(B)
[[-9.71508  4.99721  0.14246  0.05698  0.19944  0.02849  0.22793  0.79777  0.11397]
 [ 5.21856 -6.23504  2.10928  0.04371  0.15299  0.02186  0.17485  0.61196  0.08742]
 [ 1.27992  2.97972 -7.86004  0.05598  0.19594  0.02799  0.22394  0.78377  0.11197]
 [ 0.16374  0.57307  0.08187 -9.96725  4.11461  0.01637  0.13099  0.45846  0.06549]
 [ 0.15812  0.55341  0.07906  5.03162 -6.88932  2.01581  0.12649  0.44273  0.06325]
 [ 0.16264  0.56923  0.08132  1.03253  2.11385 -7.98374  0.13011  0.45539  0.06506]
 [ 0.10971  0.384    0.05486  0.02194  0.0768   0.01097 -9.91223  4.3072   0.04389]
 [ 0.14288  0.50009  0.07144  0.02858  0.10002  0.01429  5.11431 -6.59993  2.05715]
 [ 0.11229  0.39303  0.05615  0.02246  0.07861  0.01123  1.08984  2.31442 -7.95508]]
>>> stdFromPH = CdfFromPH(betap, Bp, np.arange(0.,1.1,0.1))
>>> print(stdFromPH)
[ 0.       0.06732  0.14411  0.21822  0.28688  0.34979  0.40723  0.45962  0.50738  0.55093  0.59062]
>>> stmFromME = MomentsFromME(beta, B, 5)
>>> print(stmFromME)
[1.1135106870764573, 2.411324091748754, 7.8172702796511846, 33.78557510760961, 182.52100725089716]