## DataInterpolations.jl

A library of data interpolation and smoothing functions
Popularity
19 Stars
Updated Last
4 Months Ago
Started In
August 2018

# DataInterpolations.jl

DataInterpolations.jl is a library for performing interpolations of one-dimensional data. By "data interpolations" we mean techniques for interpolating possibly noisy data, and thus some methods are mixtures of regressions with interpolations (i.e. do not hit the data points exactly, smoothing out the lines). This library can be used to fill in intermediate data points in applications like timeseries data.

## Tutorial / Demonstration

A tutorial is included and can be found at this page. To run the tutorial yourself locally, use the following Weave commands:

```using Weave, DataInterpolations
weave(joinpath(dirname(pathof(DataInterpolations)), "../Example", "DataInterpolations.jmd"), out_path=:doc)```

## API

All interpolation objects act as functions. Thus for example, using an interpolation looks like:

```u = rand(5)
t = 0:4
interp = LinearInterpolation(u,t)
interp(3.5) # Gives the linear interpolation value at t=3.5```

The indexing retreives the underlying values:

`interp # Gives the 4th value of u`

## Available Interpolations

In all cases, `u` an `AbstractVector` of values and `t` is an `AbstractVector` of timepoints corresponding to `(u,t)` pairs.

• `ConstantInterpolation(u,t)` - A piecewise constant interpolation.

• `LinearInterpolation(u,t)` - A linear interpolation.

• `QuadraticInterpolation(u,t)` - A quadratic interpolation.

• `LagrangeInterpolation(u,t,n)` - A Lagrange interpolation of order `n`.

• `QuadraticSpline(u,t)` - A quadratic spline interpolation.

• `CubicSpline(u,t)` - A cubic spline interpolation.

• `BSplineInterpolation(u,t,d,pVec,knotVec)` - An interpolation B-spline. This is a B-spline which hits each of the data points. The argument choices are:

• `d` - degree of B-spline
• `pVec` - Symbol to Parameters Vector, `pVec = :Uniform` for uniform spaced parameters and `knotVec = :ArcLen` for parameters generated by chord length method.
• `knotVec` - Symbol to Knot Vector, `knotVec = :Uniform` for uniform knot vector, `knotVec = :Average` for average spaced knot vector.
• `BSplineApprox(u,t,d,h,pVec,knotVec)` - A regression B-spline which smooths the fitting curve. The argument choices are the same as the `BSplineInterpolation`, with the additional parameter `h<length(t)` which is the number of control points to use, with smaller `h` indicating more smoothing.

• `Loess(u,t,d,α)` - A local least square regression. `d` is the degree of the polynomial to use and `α` is a smoothing parameter.

• `GPInterpolation(u,t,m,k,n=-2.0)` - A Gaussian Process interpolation via GaussianProcess.jl. Stochastic: each trajectory is different. `m` is mean function. `k` is kernel function. `n` is log standard deviation of observation noise and defaults to `-2.0`.

• Available Mean functions
• `MeanZero` - Zero mean function
• `MeanConst` - Constant mean function
• `MeanLin` - Linear mean function
• `MeanPoly` - Polynomial mean function
• Available Kernel functions (covariance functions)
• `Lin` - Linear covariance function
• `SE` - Squared exponential covariance function
• `RQ` - Rational quadratic covariance function
• `Matern` - Matern covariance function
• `Periodic` - Periodic covariance function
• `Poly` - Polnomial covariance function
• `Noise` - White noise covariance function
• `Const` - Constant (bias) covariance function
• `Curvefit(u,t,m,p,alg)` - An interpolation which is done by fitting a user-given functional form `m(t,p)` where `p` is the vector of parameters. The user's input `p` is a an initial value for a least-square fitting, `alg` is the algorithm choice to use for optimize the cost function (sum of squared deviations) via `Optim.jl` and optimal `p`s are used in the interpolation.

## Plotting

DataInterpolations.jl is tied into the Plots.jl ecosystem, by way of RecipesBase.
Any interpolation can be plotted using the `plot` command (or any other), since they have type recipes associated with them.

For convenience, and to allow keyword arguments to propagate properly, DataInterpolations.jl also defines several series types, corresponding to different interpolations.

The series types defined are:

• `:linear_interp`
• `:quadratic_interp`
• `:lagrange_interp`
• `:quadratic_spline`
• `:cubic_spline`
• `:loess`

By and large, these accept the same keywords as their function counterparts.

### Required Packages

View all packages