[SciPy-User] Cubic splines - MATLAB vs Scipy.interpolate
Charles R Harris
Tue Sep 27 18:27:02 CDT 2011
On Tue, Sep 27, 2011 at 2:27 PM, Zachary Pincus <firstname.lastname@example.org>wrote:
> scipy.signal has some cubic and quadratic spline functions:
> (and replace the c with q for the quadratic versions).
> I have no idea how fast they are, or if they're at all drop-in replacements
> for the matlab ones. The stuff in scipy.interpolate is powerful, but the
> fitpack spline-fitting operations can be a bit input-sensitive and prone to
> strange ringing.
> On Sep 27, 2011, at 3:32 PM, Charles R Harris wrote:
> > On Tue, Sep 27, 2011 at 1:04 PM, Jaidev Deshpande <
> email@example.com> wrote:
> > Hi
> > The big question: Why does the MATLAB function spline operate faster than
> the cubic spline alternatives in Scipy, especially splrep and splev ?
> > ------
> > The context: I'm working on an algorithm that bottlenecks on spline
> > Some functions in Scipy return an interpolation object function depending
> on the input data which needs to be evaluated independently over the whole
> > So I used 'lower order' functions like splrep and splev. Even that was
> too slow.
> > Then I tried to write my own code for cubic splines, generating and
> solving a system of 4N simultaneous equations for interpolation between N+1
> > No matter what I do, the code is quite slow. How come the MATLAB function
> spline operate so fast? What am I missing? What can I do to speed it up?
> > I suspect it is because the scipy routines you reference are based on
> b-splines, which are needed for least squares fits. Simple cubic spline
> interpolation through a give set of points tends to be faster and I believe
> that is what the Matlab spline function does. To get b-splines in Matlab you
> need one of the toolboxes, it doesn't come with the core. I don't think
> scipy has a simple cubic spline interpolation, but I may be wrong.
I believe the splines in signal are periodic and the boundary conditions
aren't flexible. The documentation is, um..., well, they are effectively
undocumented. We really need better spline support in scipy.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User