polysys

sofia_redux.toolkit.fitting.polynomial.polysys(samples, order, exponents=None, error=None, product=None, ignorenans=True, mask=None, info=None)[source]

Create a system of linear equations to solve n-D polynomials

I’ve tried to be as efficient as possible, storing values that will be recalculated on subsequent iterations.

Parameters:
samplesarray_like of float (ndim + 1, n_points)

samples[0] should contain the independent values of the samples in the first dimension. samples[-1] should contain the dependent values of the samples If solving for two features, samples[1] contains the independent values of the samples in the second dimension. i.e. x = samples[0], y = samples[1], z = samples[2].

orderint or array_like of int

Either a scalar polynomial order to fit across all features or an array specifying the order to fit across each dimension.

exponentsnumpy.ndarray of (int or float) (n_exponents, ndimensions)

If set will override order.

errorfloat or array_like, optional

(N,) error in dependent values

productnumpy.ndarray of numpy.float64

Pre-computed powers of the independent values in v where each dictionary element is of the form:

dimension (int) -> exponent (int or float) -> numpy.ndarray

such that:

powers[1][3] = v[1] ** 3

powers is updated if supplied. Note that each power set is unique to the v and should be deleted if v changes.

ignorenansbool, optional

If True, remove any sample points containing NaNs.

maskarray_like of bool

Mask indicating values to use (True) or ignore (False).

infodict, optional

If supplied will be updated with exponents and product

Returns:
alpha, betanumpy.ndarray, numpy.ndarray

A system of equations necessary to solve Ax=B where alpha (A) is of shape (coeffs, coeffs), beta (B) is of shape (coeffs,), and exponents contains the polynomial exponents used (coeffs, ndim)