Last updated: 2023-03-16.
tf_quant_finance.math.interpolation.cubic.interpolate#
Interpolates spline values for the given x and the spline_data.
tf_quant_finance.math.interpolation.cubic.interpolate(
x, spline_data, optimize_for_tpu=False, dtype=None, name=None
)
Constant extrapolation is performed for the values outside the domain
spline_data.x_data. This means that for x > max(spline_data.x_data),
interpolate(x, spline_data) = spline_data.y_data[-1]
and for x < min(spline_data.x_data),
interpolate(x, spline_data) = spline_data.y_data[0].
For the interpolation formula refer to p.548 of [1].
References:#
[1]: R. Sedgewick, Algorithms in C, 1990, p. 545-550. Link: http://index-of.co.uk/Algorithms/Algorithms in C.pdf
Args:#
x: A realTensorof shapebatch_shape + [num_points].spline_data: An instance ofSplineParameters.spline_data.x_datashould have the same batch shape asx.optimize_for_tpu: A Python bool. IfTrue, the algorithm uses one-hot encoding to lookup indices ofxinspline_data.x_data. This significantly improves performance of the algorithm on a TPU device but may slow down performance on the CPU. Default value:False.dtype: Optional dtype forx. Default value:Nonewhich maps to the default dtype inferred by TensorFlow.name: Pythonstrname prefixed to ops created by this function. Default value:Nonewhich is mapped to the default namecubic_spline_interpolate.
Returns:#
A Tensor of the same shape and dtype as x. Represents
the interpolated values.
Raises:#
ValueError: Ifxbatch shape is different fromspline_data.x_databatch shape.