## Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

## interp1d

One-dimensional numerical interpolation.

## Usage

(require-extension interp1d)

## 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

interp1d:nearest:procedure

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.

interp1d:linear:procedure

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.

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.

interp1d:from-sequence:procedure

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).

interp1d:lbound:procedure

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

interp1d:ubound:procedure

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

## Examples

Ivan Raikov

### Version history

1.12
Eliminated dependency on easyffi
1.11
Documentation converted to wiki format
1.10
Ported to Chicken 4
1.9
Removed testeez as a dependency
1.8
1.7
1.6
Bug fix in bounds routine
1.5
Bug fix in the sliding window routine for the case of non-list input data
1.4
Added a proper error message routine
1.3
Added a boundary exceeded error message to the sliding window routine
1.2
Build script updated for better cross-platform compatibility
1.1
1.0
Initial release

```Copyright 2007-2012 Ivan Raikov and the Okinawa Institute of Science and Technology

This program is free software: you can redistribute it and/or modify
the Free Software Foundation, either version 3 of the License, or (at

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