2 % @brief Computes stationary distribution
for level-dependent QBD processes
4 % @author QORE Lab, Imperial College London (Algorithm by Phung-Duc et al.)
8 % @brief Computes the stationary distribution
for a level-dependent QBD
11 % This function implements Algorithm 3 from the Phung-Duc et al. paper
for
12 % computing the stationary distribution of level-dependent QBD processes.
15 % 1. Boundary equation: pi_0 * (Q1^(0) + R^(1)*Q2^(1)) = 0
16 % 2. Forward recursion: pi_n = pi_{n-1} * R^(n)
17 % 3. Normalize: sum(pi) = 1
21 % pi = ldqbd_pi(R, Q0, Q1, Q2)
22 % pi = ldqbd_pi(R, Q0, Q1, Q2, options)
27 % <tr><th>Name<th>Description
28 % <tr><td>R<td>Cell array {R^(1), R^(2), ..., R^(N)} - rate matrices from ldqbd_R
29 % <tr><td>Q0<td>Cell array {Q0^(0), Q0^(1), ..., Q0^(N-1)} - upward transitions
30 % <tr><td>Q1<td>Cell array {Q1^(0), Q1^(1), ..., Q1^(N)} - local transitions
31 % <tr><td>Q2<td>Cell array {Q2^(1), Q2^(2), ..., Q2^(N)} - downward transitions
32 % <tr><td>options<td>Optional struct with fields: verbose (default false)
37 % <tr><th>Name<th>Description
38 % <tr><td>pi<td>Row vector [pi_0, pi_1, ..., pi_N] - stationary distribution
39 % (aggregated over phases at each level)
40 % <tr><td>pi_cell<td>(Optional) Cell array with full phase-level distributions
44 % T. Phung-Duc, H. Masuyama, S. Kasahara, Y. Takahashi,
"A Simple Algorithm
45 % for the Rate Matrices of Level-Dependent QBD Processes", QTNA 2010.
47function [pi, pi_cell] = ldqbd_pi(R, Q0, Q1, Q2, varargin)
50if nargin >= 5 && ~isempty(varargin{1})
51 options = varargin{1};
56if ~isfield(options,
'verbose'), options.verbose =
false; end
58% Determine number of levels
59N = length(Q1) - 1; % Maximum level
62 fprintf(
'LD-QBD Stationary Distribution: N=%d levels\n', N);
65% Check
if all levels have same dimension (homogeneous)
66isScalar = all(cellfun(@(x) numel(x) == 1, Q1));
67dims = cellfun(@(x) size(x, 1), Q1);
68isHomogeneous = (length(unique(dims)) == 1);
70if isScalar && isHomogeneous
71 % Scalar
case: direct computation
73 pi_cell = cell(N+1, 1);
75 % Start with pi_0 = 1 (will normalize later)
78 % Forward recursion: pi_n = pi_{n-1} * R^(n)
81 pi_cell{n+1} = pi_cell{n} * R{n};
87 % Convert to vector and normalize
89 pi(n+1) = pi_cell{n+1};
93 % Update pi_cell with normalized values
95 pi_cell{n+1} = pi(n+1);
98 % Heterogeneous or matrix
case: use cell array
for pi with varying dimensions
99 pi_cell = cell(N+1, 1);
101 % Initialize pi_0 based on its dimension
103 % Scalar level 0: start with pi_0 = 1
106 % Matrix level 0: solve boundary equation
109 A = Q1_0 + R{1} * Q2_1;
111 % Find null space of A
' (left null space of A)
113 [~, idx] = min(abs(diag(D)));
114 pi0 = real(V(:, idx))
';
116 % Ensure positive and normalize
121 pi0 = pi0 / sum(pi0);
125 % Forward recursion: pi_n = pi_{n-1} * R^(n)
127 pi_cell{n+1} = pi_cell{n} * R{n};
130 % Normalize and convert to vector (sum over phases at each level)
131 total = sum(cellfun(@sum, pi_cell));
134 pi_cell{n+1} = pi_cell{n+1} / total;
135 pi(n+1) = sum(pi_cell{n+1}); % Sum over phases if vector
140 fprintf(' Stationary distribution computed, sum = %.6f\n
', sum(pi));