[SciPy-User] Cubic splines - MATLAB vs Scipy.interpolate
josef.pktd@gmai...
josef.pktd@gmai...
Tue Sep 27 18:50:45 CDT 2011
On Tue, Sep 27, 2011 at 7:27 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
>
>
> On Tue, Sep 27, 2011 at 2:27 PM, Zachary Pincus <zachary.pincus@yale.edu>
> wrote:
>>
>> scipy.signal has some cubic and quadratic spline functions:
>> cspline1d
>> cspline1d_eval
>> cspline2d
>>
>> (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.
>>
>> Zach
>>
>>
>>
>> On Sep 27, 2011, at 3:32 PM, Charles R Harris wrote:
>>
>> >
>> >
>> > On Tue, Sep 27, 2011 at 1:04 PM, Jaidev Deshpande
>> > <deshpande.jaidev@gmail.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
>> > interpolation.
>> >
>> > Some functions in Scipy return an interpolation object function
>> > depending on the input data which needs to be evaluated independently over
>> > the whole range.
>> >
>> > 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
>> > points.
>> >
>> > 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.
I thought the main difference of the signal compared to interpolate
splines is that they work only on a regular grid.
They have a smoothing coefficient lambda, so they don't seem to be
pure interpolating splines.
(I never looked at them because of the regular grid restriction.)
matlab's spline has x and Y, but all the examples in the help have regular grid.
Josef
>
> Chuck
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
More information about the SciPy-User
mailing list