LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ctmc_sens.m
1function dpi = ctmc_sens(Q, dQ, pi)
2% DPI = CTMC_SENS(Q, DQ, PI)
3%
4% Sensitivity of the steady-state distribution of a CTMC to a scalar
5% parameter theta, given the generator Q, its derivative DQ = dQ/dtheta, and
6% the steady-state vector PI.
7%
8% Differentiating the balance equations pi*Q = 0 and pi*e = 1 with respect to
9% theta gives the linear system
10%
11% (dpi/dtheta) * Q = -pi * (dQ/dtheta), sum_i dpi_i/dtheta = 0,
12%
13% i.e. Trivedi and Bobbio (2017), Eq. (9.81). The system has the same
14% coefficient matrix as the steady-state solve itself, so obtaining a
15% sensitivity costs one extra solve against a matrix that is already
16% assembled. The normalization replaces one column of the singular Q, exactly
17% as in the steady-state solve.
18%
19% @param Q Generator matrix (n x n)
20% @param dQ Derivative of the generator with respect to theta (n x n)
21% @param pi Steady-state distribution (1 x n); computed if omitted
22% @return dpi Derivative of the steady-state distribution (1 x n)
23%
24% Copyright (c) 2012-2026, Imperial College London
25% All rights reserved.
26
27n = size(Q, 1);
28if nargin < 3 || isempty(pi)
29 pi = ctmc_solve(Q);
30end
31pi = pi(:)';
32
33if any(size(dQ) ~= size(Q))
34 line_error(mfilename, 'dQ must have the same size as Q');
35end
36
37% Right-hand side of Eq. (9.81)
38b = -pi * dQ;
39
40% Solve dpi * Q = b subject to sum(dpi) = 0. Transpose to column form and
41% replace the last equation by the normalization, mirroring ctmc_solve.
42A = Q';
43A(n, :) = ones(1, n);
44b = b(:);
45b(n) = 0;
46
47dpi = (A \ b)';
48end
Definition Station.m:245