Find the B-spline representation of an N-dimensional curve.
Description:
Given a list of N rank-1 arrays, x, which represent a curve in N-dimensional space parametrized by u, find a smooth approximating spline curve g(u). Uses the FORTRAN routine parcur from FITPACK
Inputs:
x – A list of sample vector arrays representing the curve. u – An array of parameter values. If not given, these values are
calculated automatically as (M = len(x[0])): v[0] = 0 v[i] = v[i-1] + distance(x[i],x[i-1]) u[i] = v[i] / v[M-1]
- ub, ue – The end-points of the parameters interval. Defaults to
- u[0] and u[-1].
- k – Degree of the spline. Cubic splines are recommended. Even values of
- k should be avoided especially with a small s-value. 1 <= k <= 5.
- task – If task==0 find t and c for a given smoothing factor, s.
- If task==1 find t and c for another value of the smoothing factor,
- s. There must have been a previous call with task=0 or task=1 for the same set of data.
- If task=-1 find the weighted least square spline for a given set of
- knots, t.
- s – A smoothing condition. The amount of smoothness is determined by
- satisfying the conditions: sum((w * (y - g))**2,axis=0) <= s where g(x) is the smoothed interpolation of (x,y). The user can use s to control the tradeoff between closeness and smoothness of fit. Larger s means more smoothing while smaller values of s indicate less smoothing. Recommended values of s depend on the weights, w. If the weights represent the inverse of the standard-deviation of y, then a good s value should be found in the range (m-sqrt(2*m),m+sqrt(2*m)) where m is the number of datapoints in x, y, and w.
t – The knots needed for task=-1. full_output – If non-zero, then return optional outputs. nest – An over-estimate of the total number of knots of the spline to
help in determining the storage space. By default nest=m/2. Always large enough is nest=m+k+1.
- per – If non-zero, data points are considered periodic with period
- x[m-1] - x[0] and a smooth periodic spline approximation is returned. Values of y[m-1] and w[m-1] are not used.
quiet – Non-zero to suppress messages.
Outputs: (tck, u, {fp, ier, msg})
- tck – (t,c,k) a tuple containing the vector of knots, the B-spline
- coefficients, and the degree of the spline.
u – An array of the values of the parameter.
fp – The weighted sum of squared residuals of the spline approximation. ier – An integer flag about splrep success. Success is indicated
if ier<=0. If ier in [1,2,3] an error occurred but was not raised. Otherwise an error is raised.msg – A message corresponding to the integer flag, ier.
Remarks:
SEE splev for evaluation of the spline and its derivatives.
splrep, splev, sproot, spalde, splint - evaluation, roots, integral bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping
of the FITPACK functions