butools.mam.FluidStationaryDistr ================================ .. currentmodule:: butools.mam .. np:function:: FluidStationaryDistr .. list-table:: :widths: 25 150 * - Matlab: - :code:`pi = FluidStationaryDistr (mass0, ini, K, clo, x)` * - Mathematica: - :code:`pi = FluidStationaryDistr [mass0, ini, K, clo, x]` * - Python/Numpy: - :code:`pi = FluidStationaryDistr (mass0, ini, K, clo, x)` Returns the stationary distribution of a Markovian fluid model at the given points. Parameters ---------- mass0 : matrix, shape (1,Np+Nm) The stationary probability vector of zero level ini : matrix, shape (1,Np) The initial vector of the stationary density K : matrix, shape (Np,Np) The matrix parameter of the stationary density clo : matrix, shape (Np,Np+Nm) The closing matrix of the stationary density x : vector, length (K) The distribution function is computed at these points. Returns ------- pi : matrix, shape (K,Nm+Np) The ith row of pi is the probability that the fluid level is less than or equal to x(i), while being in different states of the background process. Examples ======== For Matlab: >>> Q = [-6., 1., 3., 2., 0., 0.; 6., -10., 2., 0., 2., 0.; 3., 7., -12., 0., 0., 2.; 5., 0., 0., -9., 1., 3.; 0., 5., 0., 6., -13., 2.; 0., 0., 5., 3., 7., -15.]; >>> R = [2., 0., 0., 0., 0., 0.; 0., -4., 0., 0., 0., 0.; 0., 0., -12., 0., 0., 0.; 0., 0., 0., 6., 0., 0.; 0., 0., 0., 0., 0., 0.; 0., 0., 0., 0., 0., -8.]; >>> x = (0.0:1.0:30.0); >>> [mass0, ini, K, clo] = GeneralFluidSolve(Q, R); Final Residual Error for Psi: 7.6328e-16 >>> disp(mass0); 0 0.082246 0.069492 0 0.023812 0.020724 >>> disp(ini); 0.70195 0.20505 >>> disp(K); -2.4698 1.1349 1.295 -1.1686 >>> disp(clo); 0.5 0.061087 0.054574 0 0.01618 0.012595 0 0.055389 0.043116 0.16667 0.038913 0.032631 >>> y = FluidStationaryDistr(mass0, ini, K, clo, x); >>> disp(y); 0 0.082246 0.069492 0 0.023812 0.020724 0.1768 0.11964 0.10108 0.047524 0.040629 0.034482 0.25236 0.14136 0.11905 0.085106 0.051849 0.043744 0.29931 0.15521 0.13049 0.10952 0.059068 0.049706 0.32938 0.1641 0.13783 0.1252 0.063703 0.053534 0.34868 0.1698 0.14254 0.13527 0.066678 0.055991 0.36107 0.17346 0.14557 0.14173 0.068587 0.057568 0.36902 0.17581 0.14751 0.14588 0.069813 0.058581 0.37413 0.17732 0.14875 0.14854 0.070599 0.05923 0.3774 0.17829 0.14955 0.15025 0.071104 0.059647 0.37951 0.17891 0.15007 0.15134 0.071428 0.059915 0.38086 0.17931 0.1504 0.15205 0.071636 0.060087 0.38172 0.17956 0.15061 0.1525 0.07177 0.060197 0.38228 0.17973 0.15074 0.15279 0.071856 0.060268 0.38264 0.17983 0.15083 0.15298 0.071911 0.060313 0.38286 0.1799 0.15089 0.1531 0.071946 0.060343 0.38301 0.17995 0.15092 0.15317 0.071969 0.060361 0.38311 0.17997 0.15095 0.15322 0.071983 0.060373 0.38317 0.17999 0.15096 0.15325 0.071993 0.060381 0.38321 0.18 0.15097 0.15327 0.071999 0.060386 0.38323 0.18001 0.15098 0.15329 0.072002 0.060389 0.38325 0.18001 0.15098 0.1533 0.072005 0.060391 0.38326 0.18002 0.15098 0.1533 0.072006 0.060393 0.38326 0.18002 0.15098 0.1533 0.072007 0.060393 0.38327 0.18002 0.15099 0.15331 0.072008 0.060394 0.38327 0.18002 0.15099 0.15331 0.072009 0.060394 0.38327 0.18002 0.15099 0.15331 0.072009 0.060394 0.38327 0.18002 0.15099 0.15331 0.072009 0.060395 0.38327 0.18002 0.15099 0.15331 0.072009 0.060395 0.38327 0.18002 0.15099 0.15331 0.072009 0.060395 0.38327 0.18002 0.15099 0.15331 0.072009 0.060395 For Mathematica: >>> Q = {{-6., 1., 3., 2., 0., 0.},{6., -10., 2., 0., 2., 0.},{3., 7., -12., 0., 0., 2.},{5., 0., 0., -9., 1., 3.},{0., 5., 0., 6., -13., 2.},{0., 0., 5., 3., 7., -15.}}; >>> R = {{2., 0., 0., 0., 0., 0.},{0., -4., 0., 0., 0., 0.},{0., 0., -12., 0., 0., 0.},{0., 0., 0., 6., 0., 0.},{0., 0., 0., 0., 0., 0.},{0., 0., 0., 0., 0., -8.}}; >>> x = Range[0.0,30.0,1.0]; >>> {mass0, ini, K, clo} = GeneralFluidSolve[Q, R]; "Final Residual Error for Psi: "8.049116928532385*^-16 >>> Print[mass0]; {0., 0.08224612885906893, 0.06949240017690633, 0., 0.023812479297703082, 0.02072428187885746} >>> Print[ini]; {0.7019539736851326, 0.20504772142279093} >>> Print[K]; {{-2.4697521505145907, 1.134862595858089}, {1.2950177373696095, -1.1686305573375777}} >>> Print[clo]; {{0.5, 0.061087420281185266, 0.05457444259943262, 0., 0.016179786329552276, 0.012594625960258435}, {0., 0.05538937584186795, 0.04311604966168951, 0.16666666666666666, 0.03891262165047115, 0.03263123758653177}} >>> y = FluidStationaryDistr[mass0, ini, K, clo, x]; >>> Print[y]; {{0., 0.08224612885906893, 0.06949240017690633, 0., 0.023812479297703082, 0.02072428187885746}, {0.17679828584143387, 0.11964030859218046, 0.10108396370608363, 0.04752378685346968, 0.0406292470977543, 0.03448225831899647}, {0.25236302876555233, 0.1413624893371936, 0.11905425826308001, 0.08510641630266393, 0.051849121729191976, 0.043743883928920646}, {0.29931264954324033, 0.1552119530930992, 0.13049436916913887, 0.10951964597475519, 0.05906828801104183, 0.04970631314037002}, {0.32938468757051215, 0.16409771658698452, 0.13783358942358814, 0.12520170582619924, 0.06370278668078841, 0.053534155407154435}, {0.34868449515660904, 0.1698010870955941, 0.1425442744705256, 0.13526807548357628, 0.06667757320990522, 0.055991171722000466}, {0.3610724041904199, 0.17346191738358857, 0.1455679271785355, 0.1417294213170503, 0.06858700808700413, 0.057568264149546605}, {0.3690238580066053, 0.1758117034241949, 0.14750872644722962, 0.145876782363056, 0.06981262188190124, 0.058580556464752895}, {0.37412767739882563, 0.17731996646316545, 0.14875447212268095, 0.1485388594161015, 0.0705993096793801, 0.05923031906992984}, {0.3774036787247303, 0.17828807903623806, 0.1495540820182828, 0.1502475734813503, 0.07110426294589622, 0.05964738382040349}, {0.37950645389859416, 0.17890948387765165, 0.15006732962417735, 0.15134435005708705, 0.0714283785634811, 0.0599150862161234}, {0.3808561674647779, 0.17930834655920647, 0.15039676915014394, 0.15204834078408558, 0.0716364194665258, 0.06008691702319098}, {0.3817225114911861, 0.17956436554736804, 0.15060822732359253, 0.15250021307481673, 0.07176995520189747, 0.06019721049358771}, {0.38227859390074176, 0.17972869709637077, 0.15074395651087513, 0.15279025747355637, 0.0718556681187339, 0.06026800483960608}, {0.38263552790939337, 0.17983417699921528, 0.15083107734418205, 0.15297642899804645, 0.0719106848832888, 0.0603134457837539}, {0.38286463403528914, 0.1799018816485757, 0.1508869978116073, 0.15309592738064431, 0.07194599863171562, 0.06034261307635817}, {0.3830116909579996, 0.1799453394013931, 0.15092289162205835, 0.1531726301067063, 0.07196866555584394, 0.060361334759496954}, {0.38310608275321023, 0.17997323373801222, 0.15094593087205072, 0.15322186347754735, 0.07198321483119217, 0.06037335169313235}, {0.38316667025115914, 0.17999113834570535, 0.15096071913313355, 0.1532534650245694, 0.07199255361099133, 0.06038106503241529}, {0.38320555970017856, 0.18000263082107842, 0.1509702113113046, 0.1532737491886867, 0.07199854791696529, 0.06038601601281503}, {0.3832305217681999, 0.18001000752502333, 0.15097630407947565, 0.15328676903590022, 0.07200239549715055, 0.06038919391100146}, {0.38324654423330573, 0.18001474242845572, 0.1509802148598379, 0.15329512611783286, 0.0720048651530784, 0.060391233716467846}, {0.38325682861310345, 0.18001778163277804, 0.1509827250822216, 0.1533004902989391, 0.07200645035731282, 0.060392543011510216}, {0.38326342987371637, 0.1800197324144666, 0.15098433632494862, 0.15330393341929766, 0.07200746785632414, 0.060393383411997556}, {0.3832676670413954, 0.18002098456759374, 0.15098537053735236, 0.15330614346358376, 0.07200812096096232, 0.06039392284196271}, {0.3832703867628235, 0.1800217882902569, 0.15098603436985764, 0.15330756203024365, 0.07200854017087183, 0.06039426908722517}, {0.3832721324772268, 0.18002230417773518, 0.15098646046569003, 0.15330847256917773, 0.07200880925018614, 0.06039449133253881}, {0.38327325300330195, 0.18002263531172266, 0.1509867339648889, 0.15330905701908332, 0.07200898196479938, 0.06039463398569475}, {0.3832739722381797, 0.18002284785752437, 0.15098690951650454, 0.15330943216140772, 0.07200909282556067, 0.06039472555083318}, {0.3832744338952716, 0.18002298428483032, 0.15098702219825963, 0.1533096729549508, 0.0720091639840351, 0.06039478432397785}, {0.38327473022026526, 0.18002307185376684, 0.15098709452557996, 0.15330982751370525, 0.07200920965870329, 0.06039482204884339}} For Python/Numpy: >>> Q = ml.matrix([[-6., 1., 3., 2., 0., 0.],[6., -10., 2., 0., 2., 0.],[3., 7., -12., 0., 0., 2.],[5., 0., 0., -9., 1., 3.],[0., 5., 0., 6., -13., 2.],[0., 0., 5., 3., 7., -15.]]) >>> R = ml.matrix([[2., 0., 0., 0., 0., 0.],[0., -4., 0., 0., 0., 0.],[0., 0., -12., 0., 0., 0.],[0., 0., 0., 6., 0., 0.],[0., 0., 0., 0., 0., 0.],[0., 0., 0., 0., 0., -8.]]) >>> x = np.arange(0.0,31.0,1.0) >>> mass0, ini, K, clo = GeneralFluidSolve(Q, R) Final Residual Error for G: 6.661338147750939e-16 >>> print(mass0) [[ 0. 0.08225 0.06949 0. 0.02381 0.02072]] >>> print(ini) [[ 0.70195 0.20505]] >>> print(K) [[-2.46975 1.13486] [ 1.29502 -1.16863]] >>> print(clo) [[ 0.5 0.06109 0.05457 0. 0.01618 0.01259] [ 0. 0.05539 0.04312 0.16667 0.03891 0.03263]] >>> y = FluidStationaryDistr(mass0, ini, K, clo, x) >>> print(y) [[ 0. 0.08225 0.06949 0. 0.02381 0.02072] [ 0.1768 0.11964 0.10108 0.04752 0.04063 0.03448] [ 0.25236 0.14136 0.11905 0.08511 0.05185 0.04374] [ 0.29931 0.15521 0.13049 0.10952 0.05907 0.04971] [ 0.32938 0.1641 0.13783 0.1252 0.0637 0.05353] [ 0.34868 0.1698 0.14254 0.13527 0.06668 0.05599] [ 0.36107 0.17346 0.14557 0.14173 0.06859 0.05757] [ 0.36902 0.17581 0.14751 0.14588 0.06981 0.05858] [ 0.37413 0.17732 0.14875 0.14854 0.0706 0.05923] [ 0.3774 0.17829 0.14955 0.15025 0.0711 0.05965] [ 0.37951 0.17891 0.15007 0.15134 0.07143 0.05992] [ 0.38086 0.17931 0.1504 0.15205 0.07164 0.06009] [ 0.38172 0.17956 0.15061 0.1525 0.07177 0.0602 ] [ 0.38228 0.17973 0.15074 0.15279 0.07186 0.06027] [ 0.38264 0.17983 0.15083 0.15298 0.07191 0.06031] [ 0.38286 0.1799 0.15089 0.1531 0.07195 0.06034] [ 0.38301 0.17995 0.15092 0.15317 0.07197 0.06036] [ 0.38311 0.17997 0.15095 0.15322 0.07198 0.06037] [ 0.38317 0.17999 0.15096 0.15325 0.07199 0.06038] [ 0.38321 0.18 0.15097 0.15327 0.072 0.06039] [ 0.38323 0.18001 0.15098 0.15329 0.072 0.06039] [ 0.38325 0.18001 0.15098 0.1533 0.072 0.06039] [ 0.38326 0.18002 0.15098 0.1533 0.07201 0.06039] [ 0.38326 0.18002 0.15098 0.1533 0.07201 0.06039] [ 0.38327 0.18002 0.15099 0.15331 0.07201 0.06039] [ 0.38327 0.18002 0.15099 0.15331 0.07201 0.06039] [ 0.38327 0.18002 0.15099 0.15331 0.07201 0.06039] [ 0.38327 0.18002 0.15099 0.15331 0.07201 0.06039] [ 0.38327 0.18002 0.15099 0.15331 0.07201 0.06039] [ 0.38327 0.18002 0.15099 0.15331 0.07201 0.06039] [ 0.38327 0.18002 0.15099 0.15331 0.07201 0.06039]]