tools.numdiff.approx_hess2()

statsmodels.tools.numdiff.approx_hess2

statsmodels.tools.numdiff.approx_hess2(x, f, epsilon=None, args=(), kwargs={}, return_grad=False) [source]

Calculate Hessian with finite difference derivative approximation

Parameters:

x : array_like

value at which function derivative is evaluated

f : function

function of one array f(x, *args, **kwargs)

epsilon : float or array-like, optional

Stepsize used, if None, then stepsize is automatically chosen according to EPS**(1/3)*x.

args : tuple

Arguments for function f.

kwargs : dict

Keyword arguments for function f.

return_grad : bool

Whether or not to also return the gradient

Returns:

hess : ndarray

array of partial second derivatives, Hessian

grad : nparray

Gradient if return_grad == True

Notes

Equation (8) in Ridout. Computes the Hessian as:

1/(2*d_j*d_k) * ((f(x + d[j]*e[j] + d[k]*e[k]) - f(x + d[j]*e[j])) -
           (f(x + d[k]*e[k]) - f(x)) +
           (f(x - d[j]*e[j] - d[k]*e[k]) - f(x + d[j]*e[j])) -
           (f(x - d[k]*e[k]) - f(x)))

where e[j] is a vector with element j == 1 and the rest are zero and d[i] is epsilon[i].

References

Ridout, M.S. (2009) Statistical applications of the complex-step method
of numerical differentiation. The American Statistician, 63, 66-74

© 2009–2012 Statsmodels Developers
© 2006–2008 Scipy Developers
© 2006 Jonathan E. Taylor
Licensed under the 3-clause BSD License.
http://www.statsmodels.org/stable/generated/statsmodels.tools.numdiff.approx_hess2.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部