## interpolation between arrays in python

Question

What is the easiest and fastest way to interpolate between two arrays to get new array.

For example, I have 3 arrays:

```
x = np.array([0,1,2,3,4,5])
y = np.array([5,4,3,2,1,0])
z = np.array([0,5])
```

x,y corresponds to data-points and z is an argument. So at `z=0`

x array is valid, and at `z=5`

y array valid. But I need to get new array for `z=1`

. So it could be easily solved by:

`a = (y-x)/(z[1]-z[0])*1+x`

Problem is that data is not linearly dependent and there are more than 2 arrays with data. Maybe it is possible to use somehow spline interpolation?

Show source

## Answers to interpolation between arrays in python ( 1 )

This is a univariate to multivariate regression problem. Scipy supports univariate to univariate regression, and multivariate to univariate regression. But you can instead iterate over the outputs, so this is not such a big problem. Below is an example of how it can be done. I've changed the variable names a bit and added a new point:

So

`YY`

are the result for`XX`

. Hope it helps.