1function dpi = ctmc_sens(Q, dQ, pi)
2% DPI = CTMC_SENS(Q, DQ, PI)
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.
8% Differentiating
the balance equations pi*Q = 0 and pi*e = 1 with respect to
9% theta gives
the linear system
11% (dpi/dtheta) * Q = -pi * (dQ/dtheta), sum_i dpi_i/dtheta = 0,
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.
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)
24% Copyright (c) 2012-2026, Imperial College London
28if nargin < 3 || isempty(pi)
33if any(size(dQ) ~= size(Q))
34 line_error(mfilename, 'dQ must have
the same size as Q
');
37% Right-hand side of Eq. (9.81)
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.