[SciPy-user] Polynomial interpolation
LB
berthe.loic at gmail.com
Sun Apr 20 04:00:40 EDT 2008
> It appears that scipy does not have a facility for using the Lagrange
> polynomial to interpolate data. (Or did I miss it?) I am well aware of
> the numerical difficulties this poses, but it (and its generalization,
> the Hermite polynomial) does prove useful on occasion. I have written
> prototype implementations of two algorithms for evaluating this
> polynomial, and I'd like comments before submitting them for inclusion
> in scipy.
In fact, I've seen that there was a lagrange function in
scipy.interpolate
In [5]: from scipy import interpolate
In [6]: interpolate.lagrange?
Type: function
Base Class: <type 'function'>
String Form: <function lagrange at 0xb582a1ec>
Namespace: Interactive
File: /usr/lib/python2.4/site-packages/scipy/interpolate/
interpolate.py
Definition: interpolate.lagrange(x, w)
Docstring:
Return the Lagrange interpolating polynomial of the data-points
(x,w)
In scipy 0.6, this seems to be broken, because numpy's poly1d is not
imported at the top of
the interpolate module :
In [16]: scipy.__version__
Out[16]: '0.6.0'
In [17]: x = array([1, 4, 5, 7])
In [18]: y = array([0, 1, 2, 1.5])
In [19]: poly = interpolate.lagrange(x,y)
---------------------------------------------------------------------------
NameError Traceback (most recent call
last)
/usr/lib/python2.4/site-packages/scipy/interpolate/interpolate.py in
lagrange(x, w)
28 """
29 M = len(x)
---> 30 p = poly1d(0.0)
31 for j in xrange(M):
32 pt = poly1d(w[j])
NameError: global name 'poly1d' is not defined
This is related in #626.
I don't know why this function has been put aside and do not appears
in scipy.interpolate docstring.
--
LB
More information about the SciPy-User
mailing list