# rbf-interpolation

Radial basis function (RBF) network for scattered data interpolation and function approximation.

#include <mathtoolbox/rbf-interpolation.hpp>


## Math

### Overview

Given input data:

this technique calculates an interpolated value $y$ for a specified point $\mathbf{x}$ by

where $\phi(\cdot)$ is a user-selected RBF and $w_1, \cdots, w_n$ are weights that are calculated in pre-computation.

### Pre-Computation

The weight values need to be calculated in pre-computation. Let

and

where

The following linear system is solved for $\mathbf{w}$:

LU decomposition can be used for solving this problem.

### Pre-Computation with Regularization

The original formulation above is not robust (i.e., overfitting can occur) when the data points are dense and noisy.

For such scenarios, it is possible to add a regularization term into pre-computation. That is, the following minimization problem is solved:

The derivative of this objective function with respect to $\mathbf{w}$ is

Thus, the solution of the above minimization problem can be obtained by solving the below linear system:

## Usage

First, instantiate the class RbfInterpolation. Via the constructor, an RBF can be specified from the following options:

• Gaussian
• ThinPlateSpline
• InverseQuadratic
• Linear

By default, ThinPlateSpline (i.e., $\phi(x) = x^2 \log(x)$) is chosen.

Then, set the target scattered data by the method:

void SetData(const Eigen::MatrixXd& X, const Eigen::VectorXd& y);


where

represents the data points and

represents their values.

Next, calculate the weight values by the method:

void ComputeWeights(bool use_regularization = false,
double lambda = 0.001);


When use_regularization is set true, the weights are calculated in the manner of scattered data approximation, rather than scattered data interpolation. When the data is noisy, approximation is usually a better choice.

Once the above procedures are performed, the instance is ready to calculate interpolated values. This is performed by the method

double GetValue(const Eigen::VectorXd& x) const;


## Useful Resources

• Ken Anjyo, J. P. Lewis, and Frédéric Pighin. 2014. Scattered data interpolation for computer graphics. In ACM SIGGRAPH 2014 Courses (SIGGRAPH '14). ACM, New York, NY, USA, Article 27, 69 pages. DOI: https://doi.org/10.1145/2614028.2615425