package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `BPoly
]
type t = [ `BPoly | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val create : ?extrapolate:bool -> ?axis:int -> c:[> `Ndarray ] Np.Obj.t -> x:[> `Ndarray ] Np.Obj.t -> unit -> t

Piecewise polynomial in terms of coefficients and breakpoints.

The polynomial between ``xi`` and ``xi + 1`` is written in the Bernstein polynomial basis::

S = sum(ca, 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 - xi) / (xi+1 - xi)`` 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, 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. Default is True. 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

See also -------- PPoly : piecewise polynomials in the power basis

Notes ----- Properties of Bernstein polynomials are well documented in the literature, see for example 1_ 2_ 3_.

References ---------- .. 1 https://en.wikipedia.org/wiki/Bernstein_polynomial

.. 2 Kenneth I. Joy, Bernstein polynomials, http://www.idav.ucdavis.edu/education/CAGDNotes/Bernstein-Polynomials.pdf

.. 3 E. H. Doha, A. H. Bhrawy, and M. A. Saker, Boundary Value Problems, vol 2011, article ID 829546, :doi:`10.1155/2011/829543`.

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_

, 2

(x) + 2 \times b_

, 2

(x) + 3 \times b_

, 2

(x) \\ = 1 \times (1-x)^2 + 2 \times 2 x (1 - x) + 3 \times x^2

val antiderivative : ?nu:int -> [> tag ] Obj.t -> Py.Object.t

Construct a new piecewise polynomial representing the antiderivative.

Parameters ---------- nu : int, optional Order of antiderivative to evaluate. Default is 1, i.e., compute the first integral. If negative, the derivative is returned.

Returns ------- bp : BPoly Piecewise polynomial of order k + nu representing the antiderivative of this polynomial.

Notes ----- If antiderivative is computed and ``self.extrapolate='periodic'``, it will be set to False for the returned instance. This is done because the antiderivative is no longer periodic and its correct evaluation outside of the initially given x interval is difficult.

val construct_fast : ?extrapolate:Py.Object.t -> ?axis:Py.Object.t -> c:Py.Object.t -> x:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Construct the piecewise polynomial without making checks.

Takes the same parameters as the constructor. Input arguments ``c`` and ``x`` must be arrays of the correct shape and type. The ``c`` array can only be of dtypes float and complex, and ``x`` array must have dtype float.

val derivative : ?nu:int -> [> tag ] Obj.t -> Py.Object.t

Construct a new piecewise polynomial representing the derivative.

Parameters ---------- nu : int, optional Order of derivative to evaluate. Default is 1, i.e., compute the first derivative. If negative, the antiderivative is returned.

Returns ------- bp : BPoly Piecewise polynomial of order k - nu representing the derivative of this polynomial.

val extend : ?right:Py.Object.t -> c:[ `Size_k_m_ of Py.Object.t | `Ndarray of [> `Ndarray ] Np.Obj.t ] -> x:[ `Ndarray of [> `Ndarray ] Np.Obj.t | `Size of Py.Object.t ] -> [> tag ] Obj.t -> Py.Object.t

Add additional breakpoints and coefficients to the polynomial.

Parameters ---------- c : ndarray, size (k, m, ...) Additional coefficients for polynomials in intervals. Note that the first additional interval will be formed using one of the ``self.x`` end points. x : ndarray, size (m,) Additional breakpoints. Must be sorted in the same order as ``self.x`` and either to the right or to the left of the current breakpoints. right Deprecated argument. Has no effect.

.. deprecated:: 0.19

val from_derivatives : ?orders:[ `I of int | `Array_like_of_ints of Py.Object.t ] -> ?extrapolate:[ `Bool of bool | `Periodic ] -> xi:[> `Ndarray ] Np.Obj.t -> yi: [ `Ndarray of [> `Ndarray ] Np.Obj.t | `List_of_array_likes of Py.Object.t ] -> [> tag ] Obj.t -> Py.Object.t

Construct a piecewise polynomial in the Bernstein basis, compatible with the specified values and derivatives at breakpoints.

Parameters ---------- xi : array_like sorted 1-D array of x-coordinates yi : array_like or list of array_likes ``yiij`` is the ``j``th derivative known at ``xii`` orders : None or int or array_like of ints. Default: None. Specifies the degree of local polynomials. If not None, some derivatives are ignored. extrapolate : bool or 'periodic', 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. Default is True.

Notes ----- If ``k`` derivatives are specified at a breakpoint ``x``, the constructed polynomial is exactly ``k`` times continuously differentiable at ``x``, unless the ``order`` is provided explicitly. In the latter case, the smoothness of the polynomial at the breakpoint is controlled by the ``order``.

Deduces the number of derivatives to match at each end from ``order`` and the number of derivatives available. If possible it uses the same number of derivatives from each end; if the number is odd it tries to take the extra one from y2. In any case if not enough derivatives are available at one end or another it draws enough to make up the total from the other end.

If the order is too high and not enough derivatives are available, an exception is raised.

Examples --------

>>> from scipy.interpolate import BPoly >>> BPoly.from_derivatives(0, 1, [1, 2], [3, 4])

Creates a polynomial `f(x)` of degree 3, defined on `0, 1` such that `f(0) = 1, df/dx(0) = 2, f(1) = 3, df/dx(1) = 4`

>>> BPoly.from_derivatives(0, 1, 2, [0, 1], [0], [2])

Creates a piecewise polynomial `f(x)`, such that `f(0) = f(1) = 0`, `f(2) = 2`, and `df/dx(0) = 1`. Based on the number of derivatives provided, the order of the local polynomials is 2 on `0, 1` and 1 on `1, 2`. Notice that no restriction is imposed on the derivatives at ``x = 1`` and ``x = 2``.

Indeed, the explicit form of the polynomial is::

f(x) = | x * (1 - x), 0 <= x < 1 | 2 * (x - 1), 1 <= x <= 2

So that f'(1-0) = -1 and f'(1+0) = 2

val from_power_basis : ?extrapolate:[ `Bool of bool | `Periodic ] -> pp:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Construct a piecewise polynomial in Bernstein basis from a power basis polynomial.

Parameters ---------- pp : PPoly A piecewise polynomial in the power basis extrapolate : bool or 'periodic', 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. Default is True.

val integrate : ?extrapolate:[ `Periodic | `Bool of bool ] -> a:float -> b:float -> [> tag ] Obj.t -> Py.Object.t

Compute a definite integral over a piecewise polynomial.

Parameters ---------- a : float Lower integration bound b : float Upper integration bound extrapolate : ool, 'periodic', None, optional 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), use `self.extrapolate`.

Returns ------- array_like Definite integral of the piecewise polynomial over a, b

val x : t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Attribute x: get value or raise Not_found if None.

val x_opt : t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t option

Attribute x: get value as an option.

val c : t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Attribute c: get value or raise Not_found if None.

val c_opt : t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t option

Attribute c: get value as an option.

val axis : t -> int

Attribute axis: get value or raise Not_found if None.

val axis_opt : t -> int option

Attribute axis: get value as an option.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Stdlib.Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.