hessMTm#
Purpose#
Computes numerical Hessian with mask.
Format#
- h = hessMTm(&fct, par1, data1, mask)#
- Parameters:
&fct (scalar) – pointer to procedure returning either Nx1 vector or scalar.
par1 (struct) – an instance of structure of type
PV
containing parameter vector at which Hessian is to be evaluateddata1 (struct) – structure of type
DS
containing any data needed by fctmask (KxK matrix) – elements in h corresponding to elements of mask set to zero are not computed, otherwise are computed.
- 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);
// Mask
mask = { 1 1,
1 0 };
// Function to compute Hessian
proc fct(struct PV p0, struct DS d0);
local p, y;
// Unpack parameters
p = pvUnpack(p0, "P");
// Define Hessian
y = p[1] * exp( -p[2] * d0.dataMatrix);
retp(y);
endp;
// Find Hessian
h = hessMTm(&fct, p1, d0, mask);
Remarks#
par1 must be created using the pvPack()
procedures. Only lower left part of mask looked at.
Source#
hessmt.src