ostk.mathematics.curve_fitting.interpolator.Linear

class Linear(
self: ostk.mathematics.curve_fitting.interpolator.Linear,
x: numpy.ndarray[numpy.float64[m, 1]],
y: numpy.ndarray[numpy.float64[m, 1]],
)

Bases: Interpolator

Create a linear interpolator with data points.

Parameters:
  • x (numpy.array) -- The x-coordinates of data points.

  • y (numpy.array) -- The y-coordinates of data points.

Example

>>> x = numpy.array([0.0, 1.0, 2.0])
>>> y = numpy.array([0.0, 2.0, 4.0])
>>> interpolator = Linear(x, y)

Methods

compute_derivative

Overloaded function.

evaluate

Overloaded function.

generate_interpolator

Generate an interpolator of specified type with data points.

get_interpolation_type

Get the interpolation type of this interpolator.

class Type(self: ostk.mathematics.curve_fitting.Interpolator.Type, value: int)

Bases: pybind11_object

Members:

BarycentricRational

CubicSpline

Linear

property name
compute_derivative(*args, **kwargs)

Overloaded function.

  1. compute_derivative(self: ostk.mathematics.curve_fitting.interpolator.Linear, x: float) -> float

    Compute the derivative of the linear interpolation at a single point.

    Args:

    x (float): The x-coordinate to compute derivative at.

    Returns:

    float: The derivative value.

    Example:
    >>> interpolator = Linear([0.0, 1.0], [0.0, 2.0])
    >>> derivative = interpolator.compute_derivative(0.5)  # 2.0
    
  2. compute_derivative(self: ostk.mathematics.curve_fitting.interpolator.Linear, x: numpy.ndarray[numpy.float64[m, 1]]) -> numpy.ndarray[numpy.float64[m, 1]]

    Compute the derivative of the linear interpolation at multiple points.

    Args:

    x (numpy.array): The x-coordinates to compute derivatives at.

    Returns:

    (numpy.array): The derivative values.

    Example:
    >>> interpolator = Linear([0.0, 1.0], [0.0, 2.0])
    >>> derivatives = interpolator.compute_derivative([0.2, 0.8])
    
evaluate(*args, **kwargs)

Overloaded function.

  1. evaluate(self: ostk.mathematics.curve_fitting.interpolator.Linear, x: numpy.ndarray[numpy.float64[m, 1]]) -> numpy.ndarray[numpy.float64[m, 1]]

    Evaluate the linear interpolation at multiple points.

    Args:

    x (numpy.array): The x-coordinates to evaluate at.

    Returns:

    (numpy.array): The interpolated y-values.

    Example:
    >>> interpolator = Linear([0.0, 1.0], [0.0, 2.0])
    >>> result = interpolator.evaluate([0.5, 1.5])
    
  2. evaluate(self: ostk.mathematics.curve_fitting.interpolator.Linear, x: float) -> float

    Evaluate the linear interpolation at a single point.

    Args:

    x (float): The x-coordinate to evaluate at.

    Returns:

    float: The interpolated y-value.

    Example:
    >>> interpolator = Linear([0.0, 1.0], [0.0, 2.0])
    >>> result = interpolator.evaluate(0.5)  # 1.0
    
static generate_interpolator(
interpolation_type: ostk.mathematics.curve_fitting.Interpolator.Type,
x: numpy.ndarray[numpy.float64[m, 1]],
y: numpy.ndarray[numpy.float64[m, 1]],
) ostk.mathematics.curve_fitting.Interpolator

Generate an interpolator of specified type with data points.

Parameters:
  • interpolation_type (Interpolator.Type) -- The type of interpolation.

  • x (numpy.array) -- The x-coordinates of data points.

  • y (numpy.array) -- The y-coordinates of data points.

Returns:

The created interpolator.

Return type:

Interpolator

Example

>>> x = numpy.array([0.0, 1.0, 2.0])
>>> y = numpy.array([0.0, 2.0, 4.0])
>>> interpolator = Interpolator.generate_interpolator(
...     Interpolator.Type.CubicSpline, x, y
... )
get_interpolation_type(
self: ostk.mathematics.curve_fitting.Interpolator,
) ostk.mathematics.curve_fitting.Interpolator.Type

Get the interpolation type of this interpolator.

Returns:

The interpolation type.

Return type:

Interpolator.Type

Example

>>> interpolator = Interpolator(Interpolator.Type.CubicSpline)
>>> type = interpolator.get_interpolation_type()