athena.utils.local_linear_gradients

local_linear_gradients(inputs, outputs, weights=None, n_neighbors=None)[source]

Estimate a collection of gradients from input/output pairs.

Given a set of input/output pairs, choose subsets of neighboring points and build a local linear model for each subset. The gradients of these local linear models comprise estimates of sampled gradients.

Parameters
  • inputs (numpy.ndarray) – M-by-m matrix that contains the m-dimensional inputs

  • outputs (numpy.ndarray) – M-by-1 matrix that contains scalar outputs

  • weights (numpy.ndarray) – M-by-1 matrix that contains the weights for each observation (default None)

  • n_neighbors (int) – how many nearest neighbors to use when constructing the local linear model. the default value is floor(1.7*m)

Returns

M-by-m matrix that contains estimated partial derivatives approximated by the local linear models; the corresponding new inputs

Return type

numpy.ndarray, numpy.ndarray

Raises

ValueError, TypeError