1function [H, h0] = infer_lqn_jacobian(hfun, a, fdStep, fdFloor)
2% INFER_LQN_JACOBIAN Forward finite-difference sensitivity matrix of h at a.
4% [H, H0] = INFER_LQN_JACOBIAN(HFUN, A, FDSTEP, FDFLOOR) returns
the
5% sensitivity matrix H = dh/da evaluated at
the parameter vector A by forward
6% finite differences, and H0 = HFUN(A). HFUN maps a parameter vector to a
7% numeric observation vector z = h(a). This
is the approximate sensitivity
8% matrix H_k used in
the EKF update (Zheng, Yang, Woodside, Litoiu, Iszlai,
9%
"Tracking Time-Varying Parameters in Software Systems with Extended Kalman
10% Filters", CASCON 2005).
12% Each
column is H(:,i) = (HFUN(a + d_i) - H0)/d_i with
the per-parameter
13% step d_i = FDSTEP * max(|a_i|, FDFLOOR). HFUN
is evaluated numel(A)+1 times.
15% FDSTEP : relative perturbation (default 1e-3)
16% FDFLOOR : minimum absolute perturbation scale (default 1e-6)
18% Copyright (c) 2012-2026, Imperial College London
21if nargin < 3 || isempty(fdStep), fdStep = 1e-3; end
22if nargin < 4 || isempty(fdFloor), fdFloor = 1e-6; end
32 d = fdStep * max(abs(a(i)), fdFloor);
36 H(:, i) = (hi(:) - h0) / d;