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¶
insegment.points
— the points to determine the indices for. Array of any shape of total size \(M\).insegment.edges
— the edges of bins/segments of size \(N\).
Outputs¶
insegment.insegment
— array with indices of the same shape asinsegment.points
.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:
where \(e\) is an array of bin edges.
Special cases:
\(j=-1\) when \(x_i<e_0\).
\(j=N-1\) when \(x_i>=e_N\), where \(N\) is the number of edges.
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}\).