[SciPy-Dev] Confused about scipy.interpolate
Juan Luis Cano
juanlu001@gmail....
Wed Aug 14 13:23:52 CDT 2013
Hello all, I was doing some experiments for the first time with
scipy.interpolate today with the purpose of writing a brief
article/tutorial on the matter and, as a user, I got a bit confused with
the current state of the package and the "best practices". Let me explain.
The most straight-forward way I found to make a polynomial interpolation
was the funcion interp1d. It worked well, and I could even specify a
higher polynomial order so I could replicate and explain the Runge
phenomenon. Except for the fact that it refuses to work outside of the
boundaries. I had imagined that interp1d would give me some sort of
polynomial representation that could be naturally extended outside of
the domain specified by the interpolation points. Moreover, it seems to
use some "older" functions (see below).
So I read "a more recent wrapper of the FITPACK routines", and I tried
UnivariateSpline. Which naturally works inside of the domain, but cannot
have a degree higher than 5, probably because it's geared to create
splines (as the name points out). So still not valid (I wanted a 10th
degree polynomial to show the oscillations).
splmake and company are advertised as an "older" wrapping, so I felt
like not using them (for the sake of using the newer things). For
example, splmake was gone from docs
(http://mail.scipy.org/pipermail/scipy-user/2010-March/024489.html) and
besides it has an issue pending, with the word "confusing" in the title
(https://github.com/scipy/scipy/issues/1408).
And finally I found barycentric_interpolate and krogh_interpolate, which
gave me the same results but it seems one is useful if I'm adding new
points and the other is useful if I want the derivatives. But now I
wonder which one is better.
And this leads me to a question - what if I just want a simple,
arbitrary degree polynomial interpolation?
I thought that maybe something could be done similar to what was
introduced in 0.11.0 with minimize and minimize_scalar, which I think it
was a great improvement because the user usually doesn't have to worry
about the method used, unless they want to specify a certain one (even
if the naming was IMHO a bit unfortunate regarding the latter, but
that's another story). So is there a way an `interpolate` function can
be created, with a string argument specifying the method (with default
"barycentric", for example)?
Sorry for the long email, but I tried to explain in detail what was my
"path" as a user trying to figure out what to do. Hope it is useful for
the devs.
Regards
Juan Luis Cano
More information about the SciPy-Dev
mailing list