pwtools.num.PolyFit¶
- class pwtools.num.PolyFit(points, values, *args, **kwds)[source]¶
Bases:
object
High level interface to poly{fit,val}, similar to
Spline
andInterpol2D
.Arguments and keywords to
__init__()
are the same as forpolyfit()
. Keywords to__call__()
are same as forpolyval()
.- Parameters:
points (nd array (npoints,ndim)) – npoints points in ndim-space, to be fitted by a ndim polynomial f(x0,x1,…,x{ndim-1}).
values (1d array)
deg (int) – Degree of the poly (e.g. 3 for cubic).
scale (bool, optional) – Scale points and values to unity internally before fitting.
Notes
__init__: points must be (npoints,ndim) even if ndim=1.__call__: points can be (ndim,) instead of (1,ndim), need this if called in fmin()Examples
>>> fit1=polyfit(points, values, deg=3); polyval(fit1, new_points) >>> # the same >>> f1=PolyFit(points, values, 3); f1(new_points)
- __init__(points, values, *args, **kwds)[source]¶
- Parameters:
points (nd array (npoints, ndim))
values (1d array (npoints,))
**kwds (keywords to polyfit())
Methods
get_min
([x0])Minimize fit function by scipy.optimize.fmin().