interp

Contents

interp#

class brainunit.math.interp(x, xp, fp, left=None, right=None, period=None, **kwargs)#

One-dimensional linear interpolation.

Parameters:
  • x (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – The x-coordinates at which to evaluate the interpolated values.

  • xp (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – The x-coordinates of the data points, must be increasing.

  • fp (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – The y-coordinates of the data points.

  • left (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Value to return for x < xp[0].

  • right (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Value to return for x > xp[-1].

  • period (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – A period for the x-coordinates.

Returns:

out – Quantity if fp is a Quantity, else an array.

Return type:

saiunit.Quantity | Array

Examples

>>> import saiunit as u
>>> x = [1, 2, 3] * u.second
>>> xp = [0, 1, 2, 3, 4] * u.second
>>> fp = [0, 1, 2, 3, 4] * u.meter
>>> u.math.interp(x, xp, fp)