derivative_mscp

sofia_redux.toolkit.resampling.derivative_mscp(coefficients, phi_samples, derivative_map, sample_weights)[source]

Return the weighted mean-square-cross-product (mscp) of sample derivatives.

Given a polynomial equation of the form:

\[f(\Phi) = c \cdot \Phi\]

The derivative is calculated as:

\[\frac{\partial f}{\partial X_k} = \sum_{m=1}^{M} {h_{k, 0, m} \cdot c_{h_{k, 1, m}} \cdot \Phi_{h_{k, 2, m}}}\]

for an equation of \(M\) terms at the coordinate \(X\) in dimension \(k\), where \(h\) is the derivative_map and \(c\) are the coefficients. Please see polynomial_derivative_map() for a more complete description of the derivative calculation.

One the derivatives (\(g = \frac{df}{dX}\)) are calculated for all samples, they are averaged, and the cross-product is returned as:

\[\bar{g}^2 = \frac{1}{tr(W W^T)} g^T W W^T g\]

where \(W = diag(\text{weights})\).

For example, for polynomial fit of 2-dimensional data \(f(x, y)\), the returned matrix will be:

\[\begin{split}\bar{g}^2 = \begin{bmatrix} \frac{\partial f}{\partial x} \frac{\partial f}{\partial x} & \frac{\partial f}{\partial x} \frac{\partial f}{\partial y} \\ \frac{\partial f}{\partial y} \frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \frac{\partial f}{\partial y} \end{bmatrix}\end{split}\]
Parameters:
coefficientsnumpy.ndarray (n_terms,)

The coefficients of a polynomial fit for each term.

phi_samplesnumpy.ndarray (n_terms, n_samples)

The polynomial terms of the sample coordinates. Please see polynomial_exponents() for a description of this variable.

derivative_mapnumpy.ndarray

An array of shape (n_dimensions, 3, n_valid_terms). Please see polynomial_derivative_map() for an explanation of this variable.

sample_weightsnumpy.ndarray (n_samples,)

The weighting to apply to each sample when determining the weighted mean (as a multiplier).

Returns:
mscpnumpy.ndarray (n_dimensions, n_dimensions)

An array where sscp[i, j] = derivative[i] * derivative[j]. where derivative is the weighted mean derivatives over all samples.