ostk.mathematics.curve_fitting.Interpolator¶
- class Interpolator(
- self: ostk.mathematics.curve_fitting.Interpolator,
- interpolation_type: ostk.mathematics.curve_fitting.Interpolator.Type,
Bases:
pybind11_objectCreate an interpolator of specified type.
- Parameters:
interpolation_type (Interpolator.Type) -- The type of interpolation method.
Example
>>> interpolator = Interpolator(Interpolator.Type.Linear)
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, x: float) -> float
Compute the derivative of the interpolation at a single point.
- Args:
x (float): The x-coordinate to compute derivative at.
- Returns:
float: The derivative value.
- Example:
>>> interpolator = Interpolator.generate_interpolator( ... Interpolator.Type.Linear, [0.0, 1.0], [0.0, 2.0] ... ) >>> derivative = interpolator.compute_derivative(0.5) # 2.0
compute_derivative(self: ostk.mathematics.curve_fitting.Interpolator, x: numpy.ndarray[numpy.float64[m, 1]]) -> numpy.ndarray[numpy.float64[m, 1]]
Compute the derivative of the interpolation at multiple points.
- Args:
x (numpy.array): The x-coordinates to compute derivatives at.
- Returns:
(numpy.array): The derivative values.
- Example:
>>> interpolator = Interpolator.generate_interpolator( ... Interpolator.Type.Linear, [0.0, 1.0], [0.0, 2.0] ... ) >>> derivatives = interpolator.compute_derivative([0.2, 0.8])
- evaluate(*args, **kwargs)¶
Overloaded function.
evaluate(self: ostk.mathematics.curve_fitting.Interpolator, x: numpy.ndarray[numpy.float64[m, 1]]) -> numpy.ndarray[numpy.float64[m, 1]]
Evaluate the interpolation at multiple points.
- Args:
x (numpy.array): The x-coordinates to evaluate at.
- Returns:
(numpy.array): The interpolated y-values.
- Example:
>>> interpolator = Interpolator.generate_interpolator( ... Interpolator.Type.Linear, [0.0, 1.0], [0.0, 2.0] ... ) >>> result = interpolator.evaluate([0.5, 1.5])
evaluate(self: ostk.mathematics.curve_fitting.Interpolator, x: float) -> float
Evaluate the interpolation at a single point.
- Args:
x (float): The x-coordinate to evaluate at.
- Returns:
float: The interpolated y-value.
- Example:
>>> interpolator = Interpolator.generate_interpolator( ... Interpolator.Type.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]],
- 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()