InSegment transformation

Description

Return the indices of the segments to which each value in input array belongs. The InSegment transformation is used for example in exponential interpolator InterpExpo.

Inputs

  1. insegment.points — the points to determine the indices for. Array of any shape of total size \(M\).

  2. insegment.edges — the edges of bins/segments of size \(N\).

Outputs

  1. insegment.insegment — array with indices of the same shape as insegment.points.

  2. insegment.widths — the widths of segments of size \(N-1\).

Tests

Use the following commands for the usage example and testing:

./tests/elementary/test_insegment.py

Implementation

For each value \(x_i\), finds the index \(j\) such that:

\[e_j <= x_i < e_{j+1},\]

where \(e\) is an array of bin edges.

Special cases:

  1. \(j=-1\) when \(x_i<e_0\).

  2. \(j=N-1\) when \(x_i>=e_N\), where \(N\) is the number of edges.

  3. In case \(x_i\) is determined to be in bin \(j\) but close to the next bin \(j+1\) edge such that \(e_{j+1}-x_i<T\) it is reassigned to bin \(j+1\). Here \(T\) is tolerance with default value of \(T=10^{-16}\).