This should be similar to image resealing, suppose having this vector,
x = np.array([10,50,40,20])
I need to scale it up to size 10, and fill the missing values using interpolation.
Any numpy or scipy function that does this?
One way is using scipy.ndimage.interpolation.zoom. This will be zooming using spline interpolation. In order to use it you need to provide a zooming factor which in this case, given that you want an array of size 10, it should be 10/len(x):
from scipy.ndimage import interpolation
x = np.array([10,50,40,20])
i = 10
z = i / len(x)
# 2.5
x_int = interpolation.zoom(x,z)
Output
array([10, 18, 35, 50, 54, 49, 40, 30, 23, 20])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With