1function qlen = QBD_qlen_ETAQA(B,A,B0,pi,n)
2%QBD_qlen_ETAQA computes n-th moment of a Quasi-Birth-Death(QBD) process
3%
using the ETAQA method [Riska, Smirni]
6% Return value: qlen = E[qlen^n];
10% qlen=QBD_qlen_ETAQA(B,A,B0,pi,n) computes the n-th moment of Q length of a
11% QBD-type Continuous Time Markov Chain(CTMC) with an infinitesimal generator
19% where B = [B1,B2] and A = [A0,A1,A2], B0 describes the backward transition from
20% second level of states to the boundary level of states. The input pi
is the aggregated
21% probabilities computed from ETAQA method.
25% pi=QBD_qlen_ETAQA(B,A,B0,pi,n) computes the n-th moment of Q length of a
26% QBD-type Discrete Time Markov with a transition matrix of the form,
33% where B = [B1,B2] and A = [A0,A1,A2], B0 describes the backward transition from
34% second level of states to the boundary level of states. The input pi
is
35% the aggregated probabilities computed from ETAQA method
44 error(
'Matrix B0 has an incorrect number of rows');
47 error(
'Matrix B0 has an incorrect number of columns');
49if (mod(size(B,2)-mb,m) ~= 0 || (size(B,2)-mb)/m ~=1 )
50 error(
'Matrix B has an incorrect number of columns');
52if (mod(size(A, 2),m) ~= 0 || size(A,2)/m ~= 3)
53 error(
'Matrix A has an incorret number of columns');
57if abs((sum(B,2) - ones(mb,1))
'*ones(mb,1)) < 1e-12
58 % if this is a transition matrix transform it to the infinitesimal
61 A(:,m+1:2*m) = A(:,m+1:2*m) - eye(m);
62 B(:,1:mb) = B(:,1:mb) - eye(mb);
67pistar = pi(mb+m+1:mb+2*m);
69lsleft = A(:,1:m) + A(:,m+1:2*m) + A(:,2*m+1:3*m);
70lsleft = lsleft(:,1:end-1);
71lsleft = [lsleft,(A(:,2*m+1:3*m) - A(:,1:m))*ones(m,1)];
76 bk = (-1)*(2^k*pi0*B(:,mb+1:mb+m) + 2^k*pi1*A(:,m+1:2*m) + 3^k*pi1*A(:,2*m+1:3*m));
79 bkrest = bkrest + bino(k,l)*(2^l*r(k-l+1,:)*A(:,2*m+1:3*m) + r(k-l+1,:)*A(:,m+1:2*m));
82 ck = -2^k*pi1*A(:,2*m+1:3*m)*ones(m,1);
85 ckrest = ckrest + bino(k,l)*r(k-l+1,:)*A(:,2*m+1:3*m)*ones(m,1);
94qlen = sum(r(end,:),2) + sum(pi1,2);
97 function b = bino(n,k)
98 b = factorial(n)/(factorial(k)*factorial(n-k));