butools.dmap.DMRAPFromMoments ============================= .. currentmodule:: butools.dmap .. np:function:: DMRAPFromMoments .. list-table:: :widths: 25 150 * - Matlab: - :code:`H = DMRAPFromMoments(moms, Nm)` * - Mathematica: - :code:`H = DMRAPFromMoments[moms, Nm]` * - Python/Numpy: - :code:`H = DMRAPFromMoments(moms, Nm)` Creates a discrete marked rational arrival process that has the same marginal and lag-1 joint moments as given (see [1]_). Parameters ---------- moms : vector of doubles The list of marginal moments. To obtain a discrete marked rational process of order M, 2*M-1 marginal moments are required. Nm : list of matrices, shape (M,M) The list of lag-1 joint moment matrices. The length of the list determines K, the number of arrival types of the discrete rational process. Returns ------- H : list of matrices, shape (M,M) The H0, H1, ..., HK matrices of the discrete marked rational process References ---------- .. [1] Andras Horvath, Gabor Horvath, Miklos Telek, "A traffic based decomposition of two-class queueing networks with priority service," Computer Networks 53:(8) pp. 1235-1248. (2009) Examples ======== For Matlab: >>> G0 = [0.34, 0, 0; 0.06, 0.05, 0.03; 0.11, 0.13, 0]; >>> G1 = [0.3, 0, 0; 0.16, 0.18, 0.05; 0.15, 0.04, 0.09]; >>> G2 = [0, 0.01, 0; 0.1, 0.07, 0.08; 0.13, 0.12, 0.13]; >>> G3 = [0.35, 0, 0; 0, 0.18, 0.04; 0.06, 0.03, 0.01]; >>> G = {G0, G1, G2, G3}; >>> moms = MarginalMomentsFromDMRAP(G, 5); >>> disp(moms); 1.5037 3.0278 8.4243 31.097 143.88 >>> Nm = LagkJointMomentsFromDMRAP(G, 2, 1); >>> [Nm1, Nm2, Nm3] = Nm{:}; >>> disp(Nm1); 0.45395 0.68525 1.3856 0.68283 1.0318 2.0887 1.3755 2.0807 4.2171 >>> disp(Nm2); 0.026281 0.03323 0.053055 0.035051 0.043866 0.068917 0.060653 0.07477 0.11464 >>> disp(Nm3); 0.51977 0.78522 1.5891 0.78582 1.1881 2.4067 1.5917 2.4087 4.8838 >>> H = DMRAPFromMoments(moms, Nm); >>> disp(H{1}); 0.067795 0.67922 -0.42509 -0.018716 0.0035507 0.35386 -0.019902 0.039925 0.31865 >>> disp(H{2}); 0.19512 1.6571 -1.5453 -0.0081004 0.18194 0.12658 -0.0076905 0.11526 0.19294 >>> disp(H{3}); 0.25787 3.8341 -4.0555 0.12827 -1.3508 1.2347 0.12666 -1.4076 1.2929 >>> disp(H{4}); 0.17441 -0.11574 0.27606 -0.014006 -0.013671 0.37636 -0.012887 -0.0175 0.37926 >>> BuToolsCheckPrecision = 10.^-10; >>> rmoms = MarginalMomentsFromDMRAP(H, 5); >>> disp(rmoms); 1.5037 3.0278 8.4243 31.097 143.88 >>> rNm = LagkJointMomentsFromDMRAP(H, 2, 1); >>> [rNm1, rNm2, rNm3] = rNm{:}; >>> disp(rNm1); 0.45395 0.68525 1.3856 0.68283 1.0318 2.0887 1.3755 2.0807 4.2171 >>> disp(rNm2); 0.026281 0.03323 0.053055 0.035051 0.043866 0.068917 0.060653 0.07477 0.11464 >>> disp(rNm3); 0.51977 0.78522 1.5891 0.78582 1.1881 2.4067 1.5917 2.4087 4.8838 >>> disp(norm(moms-rmoms)); 3.0056e-11 For Mathematica: >>> G0 = {{0.34, 0, 0},{0.06, 0.05, 0.03},{0.11, 0.13, 0}}; >>> G1 = {{0.3, 0, 0},{0.16, 0.18, 0.05},{0.15, 0.04, 0.09}}; >>> G2 = {{0, 0.01, 0},{0.1, 0.07, 0.08},{0.13, 0.12, 0.13}}; >>> G3 = {{0.35, 0, 0},{0, 0.18, 0.04},{0.06, 0.03, 0.01}}; >>> G = {G0, G1, G2, G3}; >>> moms = MarginalMomentsFromDMRAP[G, 5]; >>> Print[moms]; {1.503697331491185, 3.027841857350894, 8.424305390832199, 31.097386717744087, 143.8804184010114} >>> Nm = LagkJointMomentsFromDMRAP[G, 2, 1]; >>> {Nm1, Nm2, Nm3} = Nm; >>> Print[Nm1]; {{0.4539462822484643, 0.6852510653292481, 1.3856372122857255}, {0.6828250179169082, 1.0317922106199087, 2.088678354109492}, {1.3754547360883858, 2.08069063568443, 4.2170625241275665}} >>> Print[Nm2]; {{0.02628103195085287, 0.03323044515488185, 0.05305519981654366}, {0.0350514750959702, 0.04386614712772344, 0.06891661923475792}, {0.06065278939554716, 0.07477024474361887, 0.11464021882832742}} >>> Print[Nm3]; {{0.5197726858006831, 0.7852158210070554, 1.5891494452486254}, {0.7858208384783067, 1.1881008368374677, 2.4066502002309207}, {1.5917343318669612, 2.4086996142807697, 4.883779522055594}} >>> H = DMRAPFromMoments[moms, Nm]; >>> Print[H[[1]]]; {{0.06779513528098983, 0.6792233137807228, -0.42509134379512803}, {-0.018716173794511234, 0.0035506821092199867, 0.3538644199083848}, {-0.019901518585921547, 0.039924500868717246, 0.31865418278856805}} >>> Print[H[[2]]]; {{0.1951207776434683, 1.6570695160216928, -1.5452971870081456}, {-0.008100374639338296, 0.18194378529369715, 0.12657574230343016}, {-0.007690549936086862, 0.115257691431907, 0.19293543687217607}} >>> Print[H[[3]]]; {{0.2578685382565766, 3.834117264599513, -4.055530267739243}, {0.12827076956352768, -1.350769988779902, 1.2347002335875743}, {0.12665640477215312, -1.4076139251314146, 1.2929014505253633}} >>> Print[H[[4]]]; {{0.1744074874552913, -0.11574488139467576, 0.27606164689950674}, {-0.014005700448463549, -0.013671167607753887, 0.3763577725021605}, {-0.012887066531690031, -0.01750028735204978, 0.3792636802754714}} >>> BuTools`CheckPrecision = 10.^-10; >>> rmoms = MarginalMomentsFromDMRAP[H, 5]; >>> Print[rmoms]; {1.5036973314912396, 3.0278418573511203, 8.424305390833059, 31.09738671774769, 143.88041840102892} >>> rNm = LagkJointMomentsFromDMRAP[H, 2, 1]; >>> {rNm1, rNm2, rNm3} = rNm; >>> Print[rNm1]; {{0.4539462822461965, 0.6852510653258723, 1.3856372122790048}, {0.6828250179124524, 1.0317922106132444, 2.0886783540961558}, {1.3754547360759344, 2.080690635665735, 4.217062524089992}} >>> Print[rNm2]; {{0.026281031950898093, 0.033230445154958294, 0.053055199816716886}, {0.03505147509598383, 0.043866147127753385, 0.06891661923484005}, {0.06065278939548402, 0.07477024474353555, 0.11464021882818698}} >>> Print[rNm3]; {{0.519772685800297, 0.7852158210065349, 1.5891494452477044}, {0.7858208384782196, 1.1881008368374257, 2.406650200231027}, {1.5917343318688073, 2.408699614283732, 4.88377952206196}} >>> Print[Norm[moms-rmoms]]; 1.7896738102973677*^-11 For Python/Numpy: >>> G0 = ml.matrix([[0.34, 0, 0],[0.06, 0.05, 0.03],[0.11, 0.13, 0]]) >>> G1 = ml.matrix([[0.3, 0, 0],[0.16, 0.18, 0.05],[0.15, 0.04, 0.09]]) >>> G2 = ml.matrix([[0, 0.01, 0],[0.1, 0.07, 0.08],[0.13, 0.12, 0.13]]) >>> G3 = ml.matrix([[0.35, 0, 0],[0, 0.18, 0.04],[0.06, 0.03, 0.01]]) >>> G = [G0, G1, G2, G3] >>> moms = MarginalMomentsFromDMRAP(G, 5) >>> print(moms) [1.503697331491185, 3.0278418573508938, 8.424305390832199, 31.097386717744087, 143.88041840101141] >>> Nm = LagkJointMomentsFromDMRAP(G, 2, 1) >>> Nm1, Nm2, Nm3 = Nm >>> print(Nm1) [[ 0.45395 0.68525 1.38564] [ 0.68283 1.03179 2.08868] [ 1.37545 2.08069 4.21706]] >>> print(Nm2) [[ 0.02628 0.03323 0.05306] [ 0.03505 0.04387 0.06892] [ 0.06065 0.07477 0.11464]] >>> print(Nm3) [[ 0.51977 0.78522 1.58915] [ 0.78582 1.1881 2.40665] [ 1.59173 2.4087 4.88378]] >>> H = DMRAPFromMoments(moms, Nm) >>> print(H[0]) [[ 0.0678 0.67922 -0.42509] [-0.01872 0.00355 0.35386] [-0.0199 0.03992 0.31865]] >>> print(H[1]) [[ 0.19512 1.65707 -1.5453 ] [-0.0081 0.18194 0.12658] [-0.00769 0.11526 0.19294]] >>> print(H[2]) [[ 0.25787 3.83412 -4.05553] [ 0.12827 -1.35077 1.2347 ] [ 0.12666 -1.40761 1.2929 ]] >>> print(H[3]) [[ 0.17441 -0.11574 0.27606] [-0.01401 -0.01367 0.37636] [-0.01289 -0.0175 0.37926]] >>> butools.checkPrecision = 10.**-10 >>> rmoms = MarginalMomentsFromDMRAP(H, 5) >>> print(rmoms) [1.5036973314922903, 3.0278418573555848, 8.4243053908503818, 31.09738671782155, 143.88041840139212] >>> rNm = LagkJointMomentsFromDMRAP(H, 2, 1) >>> rNm1, rNm2, rNm3 = rNm >>> print(rNm1) [[ 0.45395 0.68525 1.38564] [ 0.68283 1.03179 2.08868] [ 1.37545 2.08069 4.21706]] >>> print(rNm2) [[ 0.02628 0.03323 0.05306] [ 0.03505 0.04387 0.06892] [ 0.06065 0.07477 0.11464]] >>> print(rNm3) [[ 0.51977 0.78522 1.58915] [ 0.78582 1.1881 2.40665] [ 1.59173 2.4087 4.88378]] >>> print(la.norm(np.array(moms)-np.array(rmoms))) 3.8896478315352875e-10