I have forgotten

# Multivariate

Multivariate interpolation, nearest-neighbor, bilinear, multilinear, bicubic, multicubic

## Overview

Multivariate interpolation is an area of data fitting which, as opposed to univariate interpolation which fitted two-dimensional data points, finds the surface that provides an exact fit to a series of multidimensional data points. It is called multivariate since the data points are supposed to be sampled from a function of several variables.

Formally speaking, consider a series of $\inline&space;N$ distinct $\inline&space;(d&space;+&space;1)$ - dimensional data points $\inline&space;(x_1,&space;y_1)$, $\inline&space;(x_2,&space;y_2),&space;\ldots,&space;(x_N,&space;y_N)$, where $\inline&space;x_i&space;:=&space;(x_i^1,&space;x_i^2,&space;\ldots,&space;x_i^d)$ is a vector, for each $\inline&space;i&space;=&space;1,&space;2,&space;\ldots,&space;N$. By interpolating these data points we mean finding a function $\inline&space;f&space;:&space;\mathbb{R}^d&space;\to&space;\mathbb{R}$ such that:

$f(x_1)&space;=&space;y_1,&space;\quad&space;f(x_2)&space;=&space;y_2,&space;\quad&space;\ldots&space;\quad&space;f(x_N)&space;=&space;y_N.$

We will start by describing the most straightforward multivariate interpolation methods, to the more advanced. We start with the description of the method in 3D, and then explain how this generalizes to multidimensional space.

## Nearest-neighbor Interpolation

This type of interpolation basically assigns to any point $\inline&space;P(x,&space;y)$ in the plane, the value of the closest data point to $\inline&space;P$. Formally, given a series of data points $\inline&space;(x_i,&space;y_i,&space;z_i)$, for $\inline&space;i&space;=&space;1,&space;2,&space;\ldots,&space;N$, the corresponding nearest-neighbor interpolation function is given by

$f(x,&space;y)&space;=&space;f(x^*,&space;y^*)$

where $\inline&space;(x^*,&space;y^*)$ is the closest data point to $\inline&space;(x,&space;y)$ in the sense of Euclidean distance. In other words, $\inline&space;(x^*,&space;y^*)$ minimizes the following objective function

$\delta(x_i,&space;y_i)&space;:=&space;\sqrt{(x&space;-&space;x_i)^2&space;+&space;(y&space;-&space;y_i)^2}$

where $\inline&space;i&space;=&space;1,&space;2,&space;\ldots,&space;N$. The image below shows how nearest-neighbor interpolation is applied to a series of data points in the box $\inline&space;[0,&space;3]&space;\times&space;[0,&space;3]$.

In general d-dimensional space, nearest-neighbor interpolation assigns to some point $\inline&space;P(x_1,&space;x_2,&space;\ldots,&space;x_d)$ the value of the closest data point $\inline&space;P(x_1^*,&space;x_2^*,&space;\ldots,&space;x_d^*)$ to $\inline&space;P$, i.e. the one which minimizes the objective function

$\delta(x_i^1,&space;x_i^2,&space;\ldots,&space;x_i^d)&space;:=&space;\sqrt{(x_1&space;-&space;x_i^1)^2&space;+&space;(x_2&space;-&space;x_i^2)^2&space;+&space;\ldots&space;+&space;(x_d&space;-&space;x_i^d)^2}$

for all $\inline&space;i&space;=&space;1,&space;2,&space;\ldots,&space;N$, where $\inline&space;(x_i^1,&space;x_i^2,&space;\ldots,&space;x_i^d,&space;y_i)$ are the given data points.

## Bilinear Interpolation

This is a generalization of linear interpolation, from 2D to 3D data points. It is assumed that the given data points are distributed along an uniform grid, as are the points $\inline&space;Q_{11}$, $\inline&space;Q_{12}$, $\inline&space;Q_{21}$ and $\inline&space;Q_{22}$ in the image below.

The aim is to estimate the value of the function $\inline&space;f(x,&space;y)$ (from which the data points have been sampled) at point $\inline&space;P(x,&space;y)$ in the above graph. In order to do this, let us define two auxiliary functions $\inline&space;f_1,&space;f_2&space;:&space;\mathbb{R}&space;\to&space;\mathbb{R}$ through

$f_1(x)&space;:=&space;f(x,&space;y_1),&space;\qquad&space;f_2(x)&space;:=&space;f(x,&space;y_2)$

where the coordinates of $\inline&space;Q_{ij}$ are $\inline&space;(x_i,&space;y_j)$ and $\inline&space;z_{ij}&space;:=&space;f(Q_{ij})$.

The next thing is to do linear interpolation on the two-dimensional data points $\inline&space;(x_1,&space;z_{11})$, $\inline&space;(x_2,&space;z_{21})$ and $\inline&space;(x_1,&space;z_{12})$, $\inline&space;(x_2,&space;z_{22})$ correspondingly. In other words, the linear interpolation functions $\inline&space;f_1$, $\inline&space;f_2$ can be given by:

$f_1(x)&space;=&space;\frac{x_2&space;-&space;x}{x_2&space;-&space;x_1}&space;z_{11}&space;+&space;\frac{x&space;-&space;x_1}{x_2&space;-&space;x_1}&space;z_{21}\&space;\&space;,&space;\qquad&space;&space;f_2(x)&space;=&space;\frac{x_2&space;-&space;x}{x_2&space;-&space;x_1}&space;z_{12}&space;+&space;\frac{x&space;-&space;x_1}{x_2&space;-&space;x_1}&space;z_{22}$

All that is left is to do linear interpolation on the two-dimensional data points $\inline&space;(y_1,&space;f_1(x))$ and $\inline&space;(y_2,&space;f_2(x))$, providing the desired formula for the interpolation function $\inline&space;f(x,&space;y)$

$f(x,&space;y)&space;=&space;\frac{y_2&space;-&space;y}{y_2&space;-&space;y_1}&space;f_1(x)&space;+&space;\frac{y&space;-&space;y_1}{y_2&space;-&space;y_1}&space;f_2(x)$

which, with the above notations, can be written:

$\begin{array}{rl}&space;f(x,&space;y)&space;&space;&space;\approx&space;\frac{\displaystyle&space;1}{\displaystyle&space;(x_2&space;-&space;x_1)(y_2&space;-&space;y_1)}&space;&&space;\left[&space;z_{11}&space;(x_2&space;-&space;x)(y_2&space;-&space;y)&space;+&space;z_{21}&space;(x&space;-&space;x_1)(y_2&space;-&space;y)&space;+&space;\right.&space;\\&space;&space;&space;&&space;\left.&space;+&space;z_{12}&space;(x_2&space;-&space;x)(y&space;-&space;y_1)&space;+&space;z_{22}&space;(x&space;-&space;x_1)(y&space;-&space;y_1)&space;\right]&space;&space;&space;\end{array}$

This solves the problem of doing bilinear interpolation for a set of 4 three-dimensional points. If there are more than 4 points (they should however be a multiple of 2), then we repeat the above algorithm for each cell. The interpolation function over the entire domain is then defined in a piecewise manner on each cell, through the corresponding bilinear interpolation function for that cell.

The image below shows the values obtained by applying linear interpolation on the same series of data points as in the previous graph.

Using the same reasoning as above, we are able to generalize linear interpolation from some $\inline&space;d$-dimensional space to $\inline&space;(d&space;+&space;1)$-dimensional space, in a recursive manner, giving birth to multilinear interpolation. The concept of uniform grid also generalizes to multidimensional space, as seen in the article http://en.wikipedia.org/wiki/Honeycomb_(geometry) .

## Bicubic Interpolation

Without loss of generality, consider that we are given the values of the points $\inline&space;(0,&space;0)$, $\inline&space;(0,&space;1)$, $\inline&space;(1,&space;0)$ and $\inline&space;(1,&space;1)$, i.e. the corners of the unit box $\inline&space;[0,&space;1]&space;\times&space;[0,&space;1]$. Our aim is to find a bicubic function $\inline&space;p(x,&space;y)$ of the form

$p(x,&space;y)&space;:=&space;\sum_{i&space;=&space;0}^3&space;\sum_{j&space;=&space;0}^3&space;a_{ij}&space;x^i&space;y^j$

that provides an exact fit to the given data points. In order to determine $\inline&space;p$, we need to determine its coefficients $\inline&space;\displaystyle&space;a_{ij}$. This is only possible if the values of the partial derivatives $\inline&space;\displaystyle&space;\frac{\partial&space;f}{\partial&space;x}$, $\inline&space;\displaystyle&space;\frac{\partial&space;f}{\partial&space;x}$ and $\inline&space;\displaystyle&space;\frac{\partial^2&space;f}{\partial&space;x&space;\partial&space;y}$ are know at each corner of the unit box. In this case, by writing the set of linear equations

$f(T)&space;=&space;p(T),&space;\quad&space;&space;\frac{\partial&space;f}{\partial&space;x}(T)&space;=&space;\frac{\partial&space;p}{\partial&space;x}(T),&space;\quad&space;&space;\frac{\partial&space;f}{\partial&space;y}(T)&space;=&space;\frac{\partial&space;p}{\partial&space;y}(T),&space;\quad&space;&space;\frac{\partial^2&space;f}{\partial&space;x&space;\partial&space;y}(T)&space;=&space;\frac{\partial^2&space;p}{\partial&space;x&space;\partial&space;y}(T),$

for all $\inline&space;T&space;\in&space;\{(0,&space;0),&space;(0,&space;1),&space;(1,&space;0),&space;(1,&space;1)\}$, we are able to find the coefficients $\inline&space;\displaystyle&space;a_{ij}$ and completely determine the bicubic interpolation function $\inline&space;p$. As in the case of bilinear interpolation, if there are more than 4 points, then we repeat the above algorithm for each cell. The bicubic interpolation function over the entire domain is then defined in a piecewise fashion on each cell, through the corresponding bicubic interpolation function for that cell. It is also required that all the partial derivatives match on the common boundary of each pair of cells.

The following image shows the values obtained using bicubic interpolation on the same series of data points as in the previous graphs.

Generally, using bicubic instead of bilinear or nearest-neighbor interpolation results in smoother approximations and thus is more advantageous in image restoration techniques.

When generalizing this method to multidimensional space, the function $\inline&space;p$ will be of the form

$p(x_1,&space;x_2,&space;\ldots,&space;x_d)&space;:=&space;\sum_{i_1&space;=&space;0}^d&space;\sum_{i_2&space;=&space;0}^d&space;\cdots&space;\sum_{i_d&space;=&space;0}^3&space;&space;a_{i_1&space;i_2&space;\ldots&space;i_d}&space;x_1^{i_1}&space;x_2^{i_2}&space;\ldots&space;x_d^{i_d}$

and of course several other partial derivatives may come into play. The resulting system, although large, will still be linear and will allow us to find the coefficients $\inline&space;a_{i_1&space;i_2&space;\ldots&space;i_d}$ of the cubic interpolation function $\inline&space;p$. This method is also called multicubic interpolation.
Lucian Bentea (September 2008)