ostk.mathematics.curve_fitting.interpolator.CubicSpline¶
- class CubicSpline(*args, **kwargs)¶
Bases:
InterpolatorOverloaded function.
__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)
__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
Overloaded function.
Overloaded function.
Generate an interpolator of specified type with data points.
Get the interpolation type of this interpolator.
- class Type(self: ostk.mathematics.curve_fitting.Interpolator.Type, value: int)¶
Bases:
pybind11_objectMembers:
BarycentricRational
CubicSpline
Linear
- property name¶
- compute_derivative(*args, **kwargs)¶
Overloaded function.
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)
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.
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])
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]],
- x: numpy.ndarray[numpy.float64[m, 1]],
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:
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( ) ostk.mathematics.curve_fitting.Interpolator.Type¶
Get the interpolation type of this interpolator.
- Returns:
The interpolation type.
- Return type:
Example
>>> interpolator = Interpolator(Interpolator.Type.CubicSpline) >>> type = interpolator.get_interpolation_type()