Fits a polynomial curve to noisy points. Similar to LOWESS. It supports any polynomial degree
(1→linear, 2→quadratic, etc.):
and an adjustable tightness of fit (shown at 3ʳᵈ degree):
It also supports a curve of any dimension, specified through Y
.
Performs weighted polynomial regression around each output point to produce a point on a curve. Uses Gaussian weighting, the standard deviation σ
can be used to control the closeness of fit.
For each output point
where the moment matrices
The query vector
Requirements: numpy
def fit_curve(Y, resolution=10, degree=1, σ=0.8)
Y
is the data the curve will be fitted to. It's an M×N array describing M points in N dimensions.
resolution
controls the resolution of the curve by specifying how many output points to produce on the curve for each input point.
degree
is the degree of the polynomial. 1 for locally linear, 2 for locally quadratic, etc.
σ
controls the tightness of fit as the standard deviation of the Gaussian to use for blurring the moments. A higher value will produce a smoother curve.
X
specifies the spacing of input points. When not specified, the input points are assumed to be evenly spaced.