Unlike interp1d(), which only works along a single dimension with sorted data, Rbf(), radial basis function interpolation, handles scattered, irregularly-placed points in two or more dimensions by building the interpolated surface as a weighted sum of radial basis functions centered at each known data point — the function parameter selects the specific basis function shape used, 'multiquadric' by default, with alternatives like 'gaussian' and 'linear' also available. This makes it well suited for interpolating things like elevation data from unevenly-spaced survey points, where a simple grid-based method wouldn't directly apply.
1Understanding interpolate.Rbf()
Unlike interp1d(), which only works along a single dimension with sorted data, Rbf(), radial basis function interpolation, handles scattered, irregularly-placed points in two or more dimensions by building the interpolated surface as a weighted sum of radial basis functions centered at each known data point — the function parameter selects the specific basis function shape used, 'multiquadric' by default, with alternatives like 'gaussian' and 'linear' also available. This makes it well suited for interpolating things like elevation data from unevenly-spaced survey points, where a simple grid-based method wouldn't directly apply.
Use Rbf() specifically for scattered, irregularly-spaced multi-dimensional data, like unevenly-sampled 2D or 3D measurements — interp1d() and UnivariateSpline() are limited to a single dimension with ordered data, which doesn't fit scattered multi-dimensional points at all.
from scipy.interpolate import Rbf
import numpy as np
x = np.array([0, 1, 2, 3])
y = np.array([0, 0, 1, 1])
z = np.array([10, 12, 14, 18])
rbf = Rbf(x, y, z)
print(round(float(rbf(1.5, 0.5)), 2))2Practical Example
Here is a real-world application of interpolate.Rbf() showing how it is used in production SciPy code.
from scipy.interpolate import Rbf
import numpy as np
x = np.array([0, 1, 2, 3, 4])
y = np.array([0, 1, 4, 9, 16])
rbf = Rbf(x, y, function="linear")
print(round(float(rbf(2.5)), 2))3Best Practices
Follow these guidelines when working with interpolate.Rbf():
1. Use Rbf() for genuinely scattered, multi-dimensional data, rather than trying to force it into a single-dimensional interp1d()/UnivariateSpline() call
2. Experiment with different function options, multiquadric, gaussian, linear, etc., and compare results, since the best basis function choice depends on the specific data's shape
3. Be aware Rbf() can become slow and memory-intensive for a very large number of data points, since it involves solving a system scaling with the number of points
Tip: Use Rbf() specifically for scattered, irregularly-spaced multi-dimensional data, like unevenly-sampled 2D or 3D measurements — interp1d() and UnivariateSpline() are limited to a single dimension with ordered data, which doesn't fit scattered multi-dimensional points at all.
from scipy.interpolate import Rbf
import numpy as np
x = np.array([0, 1, 2, 3])
y = np.array([0, 0, 1, 1])
z = np.array([10, 12, 14, 18])
rbf = Rbf(x, y, z)
print(round(float(rbf(1.5, 0.5)), 2))