ostk.mathematics.curve_fitting.interpolator.CubicSpline

class CubicSpline(*args, **kwargs)

Bases: Interpolator

Overloaded function.

  1. __init__(self: ostk.mathematics.curve_fitting.interpolator.CubicSpline, x: numpy.ndarray[numpy.float64[m, 1]], y: numpy.ndarray[numpy.float64[m, 1]]) -> None

    Create a cubic spline interpolator with data points.

    Args:

    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, 3.0])
    >>> y = numpy.array([0.0, 1.0, 4.0, 9.0])
    >>> interpolator = CubicSpline(x, y)
    
  2. __init__(self: ostk.mathematics.curve_fitting.interpolator.CubicSpline, y: numpy.ndarray[numpy.float64[m, 1]], x_0: ostk.core.type.Real, h: ostk.core.type.Real) -> None

    Create a cubic spline interpolator with uniform spacing.

    Args:

    y (numpy.array): The y-coordinates of data points. x_0 (float): The starting x-coordinate. h (float): The uniform spacing between x-coordinates.

    Example:
    >>> y = numpy.array([0.0, 1.0, 4.0, 9.0])
    >>> interpolator = CubicSpline(y, 0.0, 1.0)  # x = [0, 1, 2, 3]
    

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.CubicSpline, x: float) -> float

    Compute the derivative of the cubic spline at a single point.

    Args:

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

    Returns:

    float: The derivative value.

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

    Compute the derivative of the cubic spline at multiple points.

    Args:

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

    Returns:

    (numpy.array): The derivative values.

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

Overloaded function.

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

    Evaluate the cubic spline interpolation at multiple points.

    Args:

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

    Returns:

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

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

    Evaluate the cubic spline interpolation at a single point.

    Args:

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

    Returns:

    float: The interpolated y-value.

    Example:
    >>> interpolator = CubicSpline([0.0, 1.0, 2.0], [0.0, 1.0, 4.0])
    >>> result = interpolator.evaluate(0.5)
    
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()