Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Avhz RustQuant Interpolation

From Leeroopedia


Knowledge Sources
Domains Numerical_Methods, Curve_Construction
Last Updated 2026-02-07 21:00 GMT

Overview

Interpolation methods for constructing continuous curves from discrete data points, supporting linear, exponential, and B-spline approaches with generic index and value types.

Description

Interpolation in RustQuant provides a trait-based framework for estimating values between known data points. The module is built around three core traits and three concrete interpolator implementations.

The Interpolator trait defines the common interface with four methods: fit() to prepare the interpolator, interpolate(point) to compute a value at a given index, range() to return the interpolation domain, and add_point() to insert new data. Two supporting traits, InterpolationIndex and InterpolationValue, constrain the types that can serve as x-axis and y-axis values respectively. Index types include all numeric primitives as well as time::Date, time::OffsetDateTime, and rust_decimal::Decimal.

LinearInterpolator performs piecewise linear interpolation by finding the two bracketing points and computing a weighted average. Given adjacent points (xl,yl) and (xr,yr), the interpolated value at x is:

y=yl+(yryl)xxlxrxl

ExponentialInterpolator uses geometric (exponential) interpolation between adjacent points. For bracketing points (xl,yl) and (xr,yr):

y=yrxxlxrxlylxrxxrxl

This is particularly useful for discount factor curves where rates compound multiplicatively.

BSplineInterpolator implements B-spline curve evaluation using the Cox-de Boor recursion algorithm. It takes a knot vector, control points, and a degree parameter, and evaluates the spline at arbitrary points within the valid range. The relationship knots.len() == control_points.len() + degree + 1 must hold.

Usage

Use linear interpolation for general-purpose curve construction where simplicity is sufficient. Use exponential interpolation for discount factor or survival probability curves where multiplicative behavior is expected. Use B-splines for smooth curve fitting with higher-order continuity requirements. All interpolators support date-indexed data, making them suitable for term structure construction.

Theoretical Basis

The Cox-de Boor algorithm evaluates B-spline basis functions recursively. For basis function Ni,p(x) of degree p:

Ni,0(x)={1if tix<ti+10otherwise

Ni,p(x)=xtiti+ptiNi,p1(x)+ti+p+1xti+p+1ti+1Ni+1,p1(x)

The interpolated value is then S(x)=iciNi,p(x) where ci are the control points.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment