Thu Jan 15 09:11:49 CST 2009
On Thu, Jan 15, 2009 at 7:42 AM, Neal Becker <firstname.lastname@example.org> wrote:
> I am interested in using interpolate.interp1d(x,y, kind='linear'), but
> instead of throwing an exception (or using a fill value) for out-of-bounds, I
> would like extrapolation. Anything in scipy useful here?
As far as I understand interpolate.interp1d needs two points to
interpolate in between, so you would need to tell it where you want it
to go outside of the range of existing points, e.g. you could create
artificial points outside of the range.
But in general this kind of extrapolation is a typical case for
regression, in the 1D case stats.linregress should do it, if x is
multivariate, then using e.g. OLS would be necessary. If your data
doesn't look linear overall, you could just use a few points close to
the boundary to estimate some local linear fit and extrapolate from
If you want a connected line, then using a predicted value from the
regression as artificial point for interp1d.
Since there are many possible ways of extrapolating, it depends on the
purpose and the shape of the x,y data.
More information about the SciPy-user