InterpExpo – exponential interpolation

Description

For a function given as \(x,y\) computes the result of exponential interpolation (linear vs \(log(y)\)) for a given vector of \(x'\). The values in \(x'\) may be unsorted.

The class inherits from InSegment transformation and thus contains two transformations: insegment, interp.

Inputs

  1. interp.newx — array of \(x'\) of any shape \(S\) of points for interpolation.

  2. interp.x — the array \(x\) of size \(N\).

  3. interp.y — the array \(y\) of size \(N\) or \(y=f(x)\) to interpolate.

  4. interp.segments — array of shape \(S\) with indices assigning each of \(x'\) to intervals of \(x\).

  5. interp.widths — widths of a segments of \(x\).

Segments and widths are naturally given by InSegment transformation transformation. When the inputs are connected via interpolate(x, y, newx) method the InSegment transformation transformation is connected automatically.

Outputs

  1. interp.interp — the result of the interpolation of shape \(S\).

Tests

Use the following commands for the usage example and testing:

./tests/elementary/test_InterpExpo.py

Implementation

For a given vectors \(x\), \(y\) and array \(x'\) the interpolation is computed the following way:

\[f(x'_i) = y_j e^{-(x'_i - x_j) b_j},\]

where \(j\) is a segment (bin) of \(x\) to which \(x'_i\) belongs to, \(x_j\) is left segment’s edge and \(y_j\) is the associated value of interpolated function. The \(b_j\) is thus:

\[b_j = - \frac{\ln(y_{j+1} / y_j)}{ x_{j+1} - x_j }.\]

For the points outside of the \([x_0, x_{N-1}]\) interval the function value is extrapolated based on first (last) segment for underflow (overflow).