gaussj_polyfit¶
- sofia_redux.toolkit.fitting.polynomial.gaussj_polyfit(samples, order, exponents=None, error=1, covar=False, ignorenans=True, info=None, mask=None, product=None, **kwargs)[source]¶
Fit a polynomial to data samples using Gauss-Jordan elimination.
Creates a system of polynomial equations, solving Ax=B using Gauss-Jordan elimination. Polynomial exponents are generated following the rules of
polynomial_exponents
.If the solution fails, all coefficients are set to NaN.
- 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 numpy.ndarray, optional
(n_points,) error in z
- covarbool, optional
If True, return the covariance
- ignorenansbool, optional
If True, remove any sample points containing NaNs.
- productnumpy.ndarray of numpy.float64, optional
Pre-calculated array to pass into
polysys
. Overrides orders and exponents.- infodict, optional
If provided will be updated with
product
andexponents
- maskarray_like of bool
array where True indicates a value to use in fitting and False is a value to ignore. Overrides
ignorenans
.- kwargsdict, optional
Currently does nothing. Just a place holder
- Returns:
- coefficients, [covariance]tuple of numpy.ndarray
The polynomial coefficients (ncoeffs,), and (optionally) the covariance matrix (ncoeffs, ncoeffs)