ostk.mathematics.curve_fitting.interpolator.ZeroOrder¶
- class ZeroOrder(
- self: ostk.mathematics.curve_fitting.interpolator.ZeroOrder,
- x: numpy.ndarray[numpy.float64[m, 1]],
- y: numpy.ndarray[numpy.float64[m, 1]],
- x: numpy.ndarray[numpy.float64[m, 1]],
Bases:
InterpolatorCreate a zero-order hold (step) interpolator with data points.
For any query value x, returns the y value of the largest data point x_i where x_i <= x. Also known as "step" or "previous value" interpolation.
- 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 = ZeroOrder(x, y) >>> interpolator.evaluate(0.5) # Returns 0.0 (value at x=0) >>> interpolator.evaluate(1.5) # Returns 2.0 (value at x=1)
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
ZeroOrder
- property name¶
- compute_derivative(*args, **kwargs)¶
Overloaded function.
compute_derivative(self: ostk.mathematics.curve_fitting.interpolator.ZeroOrder, x: float) -> float
Compute the derivative of the zero-order hold interpolation at a single point.
Note: The derivative of a step function is always 0.0 (except at discontinuities).
- Args:
x (float): The x-coordinate to compute derivative at.
- Returns:
float: The derivative value (always 0.0).
- Example:
>>> interpolator = ZeroOrder([0.0, 1.0, 2.0], [0.0, 2.0, 4.0]) >>> derivative = interpolator.compute_derivative(0.5) # 0.0
compute_derivative(self: ostk.mathematics.curve_fitting.interpolator.ZeroOrder, x: numpy.ndarray[numpy.float64[m, 1]]) -> numpy.ndarray[numpy.float64[m, 1]]
Compute the derivative of the zero-order hold interpolation at multiple points.
Note: The derivative of a step function is always 0.0 (except at discontinuities).
- Args:
x (numpy.array): The x-coordinates to compute derivatives at.
- Returns:
(numpy.array): The derivative values (always 0.0).
- Example:
>>> interpolator = ZeroOrder([0.0, 1.0, 2.0], [0.0, 2.0, 4.0]) >>> derivatives = interpolator.compute_derivative([0.2, 0.8]) # [0.0, 0.0]
- evaluate(*args, **kwargs)¶
Overloaded function.
evaluate(self: ostk.mathematics.curve_fitting.interpolator.ZeroOrder, x: numpy.ndarray[numpy.float64[m, 1]]) -> numpy.ndarray[numpy.float64[m, 1]]
Evaluate the zero-order hold interpolation at multiple points.
- Args:
x (numpy.array): The x-coordinates to evaluate at.
- Returns:
(numpy.array): The interpolated y-values (previous data point values).
- Example:
>>> interpolator = ZeroOrder([0.0, 1.0, 2.0], [0.0, 2.0, 4.0]) >>> result = interpolator.evaluate([0.5, 1.5]) # [0.0, 2.0]
evaluate(self: ostk.mathematics.curve_fitting.interpolator.ZeroOrder, x: float) -> float
Evaluate the zero-order hold interpolation at a single point.
- Args:
x (float): The x-coordinate to evaluate at.
- Returns:
float: The y-value of the previous data point.
- Example:
>>> interpolator = ZeroOrder([0.0, 1.0, 2.0], [0.0, 2.0, 4.0]) >>> result = interpolator.evaluate(0.5) # 0.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()