1% res = LevelDependentFluidStationaryDistr (masses, iniF, KF, cloF, iniB, KB, cloB, what, points)
2% calculates
the startionary distribution of first order and second order
3% level dependent fluid models
5% * masses: list of masses (K+1 vectors,
if there are K levels)
6% * iniF, KF, cloF: initial vector, matrix exponent and closing vector
for
7%
the forward direction
for each level, a list of size K
8% * iniB, KB, cloB: initial vector, matrix exponent and closing vector
for
9%
the backward direction
for each level, a list of size K
10% * what: string, can be
'pdf',
'cdf' and
'cdfm'
11% -
'pdf' returns
the (state-dependent) density
for each point
12% -
'pdfd' returns
the derivative of
the density
13% -
'cdf' returns
the distribution function,
P(X<p)
14% -
'cdfm' returns
the distribution function,
P(X<=p)
16function res = LevelDependentFluidStationaryDistr (masses, iniF, KF, cloF, iniB, KB, cloB, T, what, points)
20 N = length(masses{1});
22 function KAi = integExp(KA,L)
26 KAi = inv(-(KA-r*l)) *(eye(size(KA,1))-expm((KA-r*l)*L)) + r*l*(L+exp(-L)-1);
29 function [KAi,KBi] = integExp2(KA,KB,L)
30 if min(abs(eig(KA))) > min(abs(eig(KB)))
31 KAi = inv(-KA)*(eye(size(KA,1))-expm(KA*L));
32 KBi = integExp(KB, L);
34 KAi = integExp(KA, L);
35 KBi = inv(-KB)*(eye(size(KB,1))-expm(KB*L));
39 cummulate = strcmp(what,
'cdf') || strcmp(what,
'cdfm');
44 while k<K && p>=T(k+1)
47 [sumKF, sumKB] = integExp2(KF{k}, KB{k}, T(k+1)-T(k));
48 val = iniF{k}*sumKF*cloF{k} + iniB{k}*sumKB*cloB{k};
51 if p>T(k+1) || strcmp(what,
'cdfm')
52 pres = pres + masses{k+1};
57 if k==K && p==T(k+1) && strcmp(what,
'cdfm')
58 pres = pres + masses{k+1};
63 pres = iniF{k}*expm(KF{k}*prem)*cloF{k} + iniB{k}*expm(KB{k}*(Tk-prem))*cloB{k};
64 elseif strcmp(what,
'pdfd')
65 pres = iniF{k}*KF{k}*expm(KF{k}*prem)*cloF{k} - iniB{k}*KB{k}*expm(KB{k}*(Tk-prem))*cloB{k};
66 elseif strcmp(what,
'cdf') || strcmp(what,
'cdfm')
67 [sumKF, sumKB] = integExp2(KF{k}, KB{k}, prem);
68 pres = pres + iniF{k}*sumKF*cloF{k} + iniB{k}*expm(KB{k}*(Tk-prem))*sumKB*cloB{k};