hessMTTgw¶
Purpose¶
Computes numerical Hessian using gradient procedure with weights and using available threads.
Format¶
-
h =
hessMTTgw
(&gfct, par1, data1, wgts)¶ - Parameters
gfct (scalar) – pointer to procedure computing either 1xK gradient or NxK Jacobian
par1 (struct) – structure of type
PV
containing parameter vector at which Hessian is to be evaluateddata1 (struct) – structure of type
DS
containing any data needed by fctwgts (Nx1 vector) – weights
- Returns
h (KxK matrix) – Hessian
Examples¶
// Define a PV structure
struct PV p1;
// Create p1 PV structure
p1 = pvCreate;
// Fill PV structure
p1 = pvPack(p1, 0.1|0.2, "P");
// Create data matrix
x = seqa(1, 1, 15);
// Define weights
wgts = zeros(5,1) | ones(10,1);
// Function to compute Hessian
proc gfct(struct PV p0, x);
local p, g1, g2;
// Unpack parameters
p = pvUnpack(p0, "P");
// Define Hessian
g1 = exp(-p[2] * x);
g2 = -p[1] * x .* g1;
retp(g1~g2);
endp;
// Find Hessian
h = hessMTTgw(&gfct, p1, x, wgts);
Source¶
hessmtt.src