If this line
new_x = np.linspace(x.min(), x.max(), new_length)
generates an error message
AttributeError: 'function' object has no attribute 'min'
then x is a function, and functions (generally speaking) do not have min attributes, so you cannot call some_function.min() . What is x ? In your code, you only defined it as
x=var
I'm not sure what var . var not built-in by default in Python, but if it is a function, you either defined it yourself for some reason, or you selected it from somewhere (say you use Sage, or you did, for example, from sympy import * or something like that.)
[Update: since you say you are using "PyLab", maybe var is numpy.var , which was imported into the scope at startup in IPython. I think you really mean "using IPython in --pylab mode.]
You also define x1 and y1 , but then your later code refers to x and y , so it looks like this code is halfway between two functional states.
Now numpy arrays have a .min() and .min() method, so this is:
>>> x = np.array([0.1, 0.3, 0.4, 0.7]) >>> y = np.array([0.2, 0.5, 0.6, 0.9]) >>> new_length = 25 >>> new_x = np.linspace(x.min(), x.max(), new_length) >>> new_y = sp.interpolate.interp1d(x, y, kind='cubic')(new_x)
will work. Your test data will not be related to the fact that at least 4 points are required for interpolation, and you will receive
ValueError: x and y arrays must have at least 4 entries