This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / interpolate / _interpolate / BPoly

class

scipy.interpolate._interpolate:BPoly

source: build-install/usr/lib/python3.14/site-packages/scipy/interpolate/_interpolate.py:1851

Signature

class BPoly(c, x, extrapolate = None, axis = 0)

Members

Summary

Piecewise polynomial in the Bernstein basis.

Extended Summary

The polynomial between x[i] and x[i + 1] is written in the Bernstein polynomial basis

S = sum(c[a, i] * b(a, k; x) for a in range(k+1)),

where k is the degree of the polynomial, and

b(a, k; x) = binom(k, a) * t**a * (1 - t)**(k - a),

with t = (x - x[i]) / (x[i+1] - x[i]) and binom is the binomial coefficient.

Parameters

c : ndarray, shape (k, m, ...)

Polynomial coefficients, order k and m intervals

x : ndarray, shape (m+1,)

Polynomial breakpoints. Must be sorted in either increasing or decreasing order.

extrapolate : {bool, 'periodic', None}, optional

If bool, determines whether to extrapolate to out-of-bounds points based on first and last intervals, or to return NaNs. If 'periodic', periodic extrapolation is used. If None (default), it is set to True. See tutorial-interpolate_out_of_bounds.

axis : int, optional

Interpolation axis. Default is zero.

Attributes

x : ndarray

Breakpoints.

c : ndarray

Coefficients of the polynomials. They are reshaped to a 3-D array with the last dimension representing the trailing dimensions of the original coefficient array.

axis : int

Interpolation axis.

Methods

__call__
extend
derivative
antiderivative
integrate
construct_fast
from_power_basis
from_derivatives

Notes

Properties of Bernstein polynomials are well documented in the literature, see for example [1] [2] [3].

Examples

from scipy.interpolate import BPoly
x = [0, 1]
c = [[1], [2], [3]]
bp = BPoly(c, x)
✓
This creates a 2nd order polynomial .. math:: B(x) = 1 \times b_{0, 2}(x) + 2 \times b_{1, 2}(x) + 3 \times b_{2, 2}(x) \\ = 1 \times (1-x)^2 + 2 \times 2 x (1 - x) + 3 \times x^2

See also

PPoly

piecewise polynomials in the power basis

Aliases

  • scipy.interpolate.BPoly

Referenced by