Description

One-dimensional numerical interpolation.

Author

Ivan Raikov

Version

Requires

Usage

(require-extension interp1d)

Download

interp1d.egg

Documentation

The interp1d library provides routines for linear and piecewise quadratic interpolation, as well as a facility for "sliding window" interpolation over a long, or possibly infinite, sequence of data.

Procedures

procedure: interp1d:nearest:: XDATA * YDATA * X -> Y

Interpolates function y=f(x) at the point x using the data point nearest to x. Arguments XDATA and YDATA are lists of numeric values that correspond to sample points of the function being interpolated. Argument X must be within the range of values contained in XDATA.

procedure: interp1d:linear:: XDATA * YDATA * X -> Y

Interpolates function y=f(x) at the point x using the linear interpolation method. Arguments XDATA and YDATA are lists of numeric values that correspond to sample points of the function being interpolated. Argument X must be within the range of values contained in XDATA.

procedure: interp1d:piecewise-quadratic:: XDATA * YDATA * X -> Y

Interpolates function y=f(x) at the point x using the piecewise quadratic interpolation method. Arguments XDATA and YDATA are lists of numeric values that corresponds to sample points of the function being interpolated. Argument X must be within the range of values contained in XDATA.

procedure: interp1d:from-sequence:: METHOD * STEP * YDATA [* START * CAR * CDR * NULL? * DELTA-WINDOW-LEN * MAX-WINDOW-LEN] -> (LAMBDA X -> Y)

Constructs a sliding window interpolation procedure, for a given sequence YDATA that contains uniformly sampled values of a function y = f(x), where X has an initial value of START (default 0) and is incremented by STEP amount. The returned procedure performs interpolation using the given METHOD procedure, while the window is shifted forwards by the appropriate amount if X is outside the current window range. Backward shifting is not supported.

Argument METHOD is one of the interpolation procedures above.

Optional argument START specifies the initial (smallest) X and defaults to 0.

Optional arguments CAR, CDR, NULL? are used to access YDATA and default to the standard list procedures. If the input sequence is not a list (e.g. an SRFI-40 stream), these arguments can be used to specify the appropriate accessors and predicates.

Optional arguments DELTA-WINDOW-LEN and MAX-WINDOW-LEN specify the window increment (default 4) and maximum window size (default 128).

procedure: interp1d:lbound:: XDATA * YDATA * X -> Y

Returns the value of the data point nearest to X that does not exceed the value of X.

procedure: interp1d:ubound:: XDATA * YDATA * X -> Y

Returns the value of the data point nearest to X that is larger than X.

Examples

License

Copyright 2007 Ivan Raikov and the Okinawa Institute of Science and Technology.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

A full copy of the GPL license can be found at
<http://www.gnu.org/licenses/>.