commons-math-interpolation
This package is a partial TypeScript port of the interpolation classes of the Apache Commons Math library, with some extensions.
The following forms of interpolation are implemented:
- Akima cubic spline interpolation
- Natural cubic spline interpolation
- Linear interpolation
- Nearest neighbor interpolation
The interpolators work on a dataset of x/y points (knots) and return a function f(x).
Additionally, a local regression algorithm is implemented that can be used in conjunction with the above interpolators.
Interpolation demo: www.source-code.biz/snippets/typescript/akima
LOESS demo: www.source-code.biz/snippets/typescript/loess
NPM package: commons-math-interpolation
Usage
An example program is in the examples directory.
For Akima:
import {createAkimaSplineInterpolator} from "commons-math-interpolation";
const f = createAkimaSplineInterpolator([0, 1, 3, 4, 7], [2, 5, 4, 1, 3]);
console.log(f(2.5));
The LOESS functions and types are imported from the Loess module:
import {createLoessInterpolator} from "commons-math-interpolation/Loess";
const f = createLoessInterpolator({xVals, yVals, bandwidthFraction: 0.3});
Modules
| Module | Description |
|---|---|
| Akima | Akima cubic spline interpolation. |
| BasicInterpolators | Dispatcher for the basic interpolation methods (without LOESS). |
| Cubic | Natural cubic spline interpolation. |
| Index | Main entry point of the package. |
| Linear | Linear interpolation. |
| Loess | LOESS/LOWESS local regression. |
| NearestNeighbor | Nearest neighbor interpolation. |
| Utils | Utility functions and types used by the other modules of this package. |