Splines with Python (using control knots and endpoints)
Question: I'm trying to do something like the following (image extracted from wikipedia)

![spline](http://i.stack.imgur.com/c6VFl.png)

    
    
    #!/usr/bin/env python
    from scipy import interpolate
    import numpy as np
    import matplotlib.pyplot as plt
    
    # sampling
    x = np.linspace(0, 10, 10)
    y = np.sin(x)
    
    # spline trough all the sampled points
    tck = interpolate.splrep(x, y)
    x2 = np.linspace(0, 10, 200)
    y2 = interpolate.splev(x2, tck)
    
    # spline with all the middle points as knots (not working yet)
    # knots = x[1:-1]  # it should be something like this
    knots = np.array([x[1]])  # not working with above line and just seeing what this line does
    weights = np.concatenate(([1],np.ones(x.shape[0]-2)*.01,[1]))
    tck = interpolate.splrep(x, y, t=knots, w=weights)
    x3 = np.linspace(0, 10, 200)
    y3 = interpolate.splev(x2, tck)
    
    # plot
    plt.plot(x, y, 'go', x2, y2, 'b', x3, y3,'r')
    plt.show()
    

The first part of the code is the code extracted from [the main
reference](http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.splrep.html)
but it's not explained how to use the points as control knots.

The result of this code is the following image.

![enter image description here](http://i.stack.imgur.com/cbI1l.png)

The points are the samples, the blue line is the spline taking into account
all the points. And the red line is the one that is not working for me. I'm
trying to take into account **all the intermediate points as control knots**
but I just can't. If I try to use `knots=x[1:-1]` it just doesn't work. I'd
appreciate any help.

**Question in short** : how do I use all the intermediate points as control
knots in the spline function?

Note: this last image is exactly what I need, and it's the difference between
what I have (spline passing all the points) and what I need (spline with
control knots). Any ideas? ![enter image description
here](http://i.stack.imgur.com/Bnint.gif)


Answer: In this IPython Notebook
<http://nbviewer.ipython.org/github/empet/geom_modeling/blob/master/FP-Bezier-
Bspline.ipynb> you can find a detailed description of data involved in
generating a B-spline curve, as well as the Python implementation of the de
Boor algorithm.

