datapoints in `x`, `y`, and `w`. default : ``s=m-sqrt(2*m)`` if weights are supplied. ``s = 0.0`` (interpolating) if no weights are supplied. t : array_like, optional The knots needed for ``task=-1``. If given then task is automatically set to ``-1``. full_output : bool, optional If non-zero, then return optional outputs. per : bool, optional 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. The default is zero, corresponding to boundary condition 'not-a-knot'. quiet : bool, optional Non-zero to suppress messages. Returns ------- tck : tuple A tuple ``(t,c,k)`` containing the vector of knots, the B-spline coefficients, and the degree of the spline. fp : array, optional The weighted sum of squared residuals of the spline approximation. ier : int, optional 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 : str, optional A message corresponding to the integer flag, `ier`. See Also -------- UnivariateSpline, BivariateSpline splprep, splev, sproot, spalde, splint bisplrep, bisplev BSpline make_interp_spline Notes ----- See `splev` for evaluation of the spline and its derivatives. Uses the FORTRAN routine ``curfit`` from FITPACK. The user is responsible for assuring that the values of `x` are unique. Otherwise, `splrep` will not return sensible results. If provided, knots `t` must satisfy the Schoenberg-Whitney conditions, i.e., there must be a subset of data points ``x[j]`` such that ``t[j] < x[j] < t[j+k+1]``, for ``j=0, 1,...,n-k-2``. This routine zero-pads the coefficients array ``c`` to have the same length as the array of knots ``t`` (the trailing ``k + 1`` coefficients are ignored by the evaluation routines, `splev` and `BSpline`.) This is in contrast with `splprep`, which does not zero-pad the coefficients. The default boundary condition is 'not-a-knot', i.e. the first and second segment at a curve end are the same polynomial. More boundary conditions are available in `CubicSpline`. References ---------- Based on algorithms described in [1]_, [2]_, [3]_, and [4]_: .. [1] P. Dierckx, "An algorithm for smoothing, differentiation and integration of experimental data using spline functions", J.Comp.Appl.Maths 1 (1975) 165-184. .. [2] P. Dierckx, "A fast algorithm for smoothing data on a rectangular grid while using spline functions", SIAM J.Numer.Anal. 19 (1982) 1286-1304. .. [3] P. Dierckx, "An improved algorithm for curve fitting with spline functions", report tw54, Dept. Computer Science,K.U. Leuven, 1981. .. [4] P. Dierckx, "Curve and surface fitting with splines", Monographs on Numerical Analysis, Oxford University Press, 1993. Examples -------- You can interpolate 1-D points with a B-spline curve. Further examples are given in :ref:`in the tutorial `. >>> import numpy as np >>> import matplotlib.pyplot as plt >>> from scipy.interpolate import splev, splrep >>> x = np.linspace(0, 10, 10) >>> y = np.sin(x) >>> spl = splrep(x, y) >>> x2 = np.linspace(0, 10, 200) >>> y2 = splev(x2, spl) >>> plt.plot(x, y, 'o', x2, y2) >>> plt.show() )