nonlinear_polyfit¶
- sofia_redux.toolkit.fitting.polynomial.nonlinear_polyfit(samples, order, exponents=None, error=1, product=None, mask=None, covar=False, ignorenans=True, info=None, **kwargs)[source]¶
Solve for polynomial coefficients using non-linear least squares fit
- 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.
- exponentsarray_like of (int or float) (n_exponents, ndimensions)
If set will override
order
.- errorfloat or array_like of float, optional
(n_points,) error in z
- covarbool, optional
If True, return the covariance
- ignorenansbool, optional
If True, remove any sample points containing NaNs.
- infodict, optional
If provided will be updated with
product
andexponents
. Note thatproduct
will always be None for nonlinear fitting.- productnumpy.ndarray of numpy.float64, optional
Not used.
- 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
Additional keyword arguments to
scipy.optimize.curve_fit
- Returns:
- coefficients, exponents, [covariance]tuple of numpy.ndarray
The polynomial coefficients (ncoeffs,), the polynomial exponents (ncoeffs, ndim), and (optionally) the covariance matrix (ncoeffs, ncoeffs)