# [SciPy-User] Interpolation of function on a line vs 2D interpolation

Robert Kern robert.kern@gmail....
Thu Apr 8 11:34:12 CDT 2010

```On Thu, Apr 8, 2010 at 11:21, igor Halperin <ighalp@gmail.com> wrote:
> Hi,
> I am a bit stuck with the following interpolation problem. I have to compute
> a function
> z = f(x,y) whose arguments are realizations of components of a
> two-dimensional random  variable (X,Y), obtained by Monte Carlo. As each
> Monte Carlo simulation gives me a pair (x(t), y(t)) where t = 0,...,N-1
> enumerates Monte Carlo runs, I can equivalently say that my function f is
> defined on a discretized line t = 0,..., N-1 in a 2D space. Now, as
> calculation of function f is costly but the function itself is smooth, I
> want to calculate it on a sparse subset of simulated 2D points (x(t),y(t)),
> and then interpolate for the rest of points.  (my sparse set includes
> scenarios providing extreme values of x,y to avoid the need to
> extrapolate).
> Though this problem could be viewed as a 2D interpolation and solved using
> function interpolate.bisplrep, in practice I run out of memory with this
> method as the number N of 2D points is about 100,000, and I get memory error
> when trying to produce matrices of dimension 100,000x100,000 needed for
> interpolate.bisplrep using function meshgrid.

Why would you use meshgrid? Can you show us the code you are trying?
It might be easier to see the problems that way.

> However, in view of what is
> said above,
> the problem can alternatively be viewed as interpolation of a function
> defined on a line.

No, not really. You will not get sensible results if you try that.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
```