tools.numdiff.approx_fprime()

statsmodels.tools.numdiff.approx_fprime

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

Gradient of function, or Jacobian if function f returns 1d array

Parameters:

x : array

parameters at which the derivative is evaluated

f : function

f(*((x,)+args), **kwargs) returning either one value or 1d array

epsilon : float, optional

Stepsize, if None, optimal stepsize is used. This is EPS**(1/2)*x for centered == False and EPS**(1/3)*x for centered == True.

args : tuple

Tuple of additional arguments for function f.

kwargs : dict

Dictionary of additional keyword arguments for function f.

centered : bool

Whether central difference should be returned. If not, does forward differencing.

Returns:

grad : array

gradient or Jacobian

Notes

If f returns a 1d array, it returns a Jacobian. If a 2d array is returned by f (e.g., with a value for each observation), it returns a 3d array with the Jacobian of each observation with shape xk x nobs x xk. I.e., the Jacobian of the first observation would be [:, 0, :]

© 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_fprime.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部