libb.linterp
- linterp(x0, x1, x, y0, y1, *, inf_value=None)[source]
Linearly interpolate y between y0 and y1 based on x’s position.
- Parameters:
x0 – Start of x range.
x1 – End of x range.
x – Value to interpolate at.
y0 – Y value at x0.
y1 – Y value at x1.
inf_value – Value to return when x1 is infinity (default: y0).
- Returns:
Interpolated y value.
- Return type:
Example:
>>> linterp(1, 3, 2, 2, 4) 3.0 >>> linterp(1, float('inf'), 2, 2, 4) 2.0 >>> linterp(1, float('inf'), 2, 2, 4, inf_value=4) 4.0