Interpolate values at query points using piecewise linear segments.
Numeric.math.interp(query, points, values, lower, right, period)Performs piecewise linear interpolation between known points.
- Parameters:
query: Positions where values are requestedpoints: Sorted sample positions of the known valuesvalues: Sample values paired with the positionslower: Value returned for queries below the rangeright: Value returned for queries above the rangeperiod: Optional period for cyclic interpolation
- Returns: Interpolated values at the query positions
- NumPy: Equivalent to
np.interp.
import Numeric from '@neabyte/numerix'
const value = Numeric.math.interp(2.5, [0, 1, 2, 3], [0, 10, 20, 30])
console.log(value)
// 25import Numeric from '@neabyte/numerix'
const values = Numeric.math.interp([0.5, 1.5], [0, 1, 2], [0, 10, 20])
console.log(values)
// [5,15]import Numeric from '@neabyte/numerix'
const value = Numeric.math.interp(1, [0, 1, 2], [0, 10, 20])
console.log(value)
// 10import Numeric from '@neabyte/numerix'
const value = Numeric.math.interp(-1, [0, 1, 2], [0, 10, 20], -99, 99)
console.log(value)
// -99