package scipy

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

PCHIP 1-d monotonic cubic interpolation.

``x`` and ``y`` are arrays of values used to approximate some function f, with ``y = f(x)``. The interpolant uses monotonic cubic splines to find the value of new points. (PCHIP stands for Piecewise Cubic Hermite Interpolating Polynomial).

Parameters ---------- x : ndarray A 1-D array of monotonically increasing real values. ``x`` cannot include duplicate values (otherwise f is overspecified) y : ndarray A 1-D array of real values. ``y``'s length along the interpolation axis must be equal to the length of ``x``. If N-D array, use ``axis`` parameter to select correct axis. axis : int, optional Axis in the y array corresponding to the x-coordinate values. extrapolate : bool, optional Whether to extrapolate to out-of-bounds points based on first and last intervals, or to return NaNs.

Methods ------- __call__ derivative antiderivative roots

See Also -------- CubicHermiteSpline Akima1DInterpolator CubicSpline PPoly

Notes ----- The interpolator preserves monotonicity in the interpolation data and does not overshoot if the data is not smooth.

The first derivatives are guaranteed to be continuous, but the second derivatives may jump at :math:`x_k`.

Determines the derivatives at the points :math:`x_k`, :math:`f'_k`, by using PCHIP algorithm 1_.

Let :math:`h_k = x_k+1 - x_k`, and :math:`d_k = (y_k+1 - y_k) / h_k` are the slopes at internal points :math:`x_k`. If the signs of :math:`d_k` and :math:`d_k-1` are different or either of them equals zero, then :math:`f'_k = 0`. Otherwise, it is given by the weighted harmonic mean

.. math::

\fracw_1 + w_2f'_k = \fracw_1d_{k-1

}

  1. \fracw_2d_k

where :math:`w_1 = 2 h_k + h_k-1` and :math:`w_2 = h_k + 2 h_k-1`.

The end slopes are set using a one-sided scheme 2_.

References ---------- .. 1 F. N. Fritsch and R. E. Carlson, Monotone Piecewise Cubic Interpolation, SIAM J. Numer. Anal., 17(2), 238 (1980). :doi:`10.1137/0717021`. .. 2 see, e.g., C. Moler, Numerical Computing with Matlab, 2004. :doi:`10.1137/1.9780898717952`

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

Construct a new piecewise polynomial representing the antiderivative.

Antiderivative is also the indefinite integral of the function, and derivative is its inverse operation.

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 ------- pp : PPoly Piecewise polynomial of order k2 = k + n representing the antiderivative of this polynomial.

Notes ----- The antiderivative returned by this function is continuous and continuously differentiable to order n-1, up to floating point rounding error.

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 ------- pp : PPoly Piecewise polynomial of order k2 = k - n representing the derivative of this polynomial.

Notes ----- Derivatives are evaluated piecewise for each polynomial segment, even if the polynomial is not differentiable at the breakpoints. The polynomial intervals are considered half-open, ``a, b)``, except for the last interval which is closed ``[a, b]``.

val extend : ?right:Py.Object.t -> c:[ `Ndarray of [> `Ndarray ] Np.Obj.t | `Size_k_m_ of Py.Object.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_bernstein_basis : ?extrapolate:[ `Bool of bool | `Periodic ] -> bp:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

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

Parameters ---------- bp : BPoly A Bernstein basis polynomial, as created by BPoly 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 from_spline : ?extrapolate:[ `Bool of bool | `Periodic ] -> tck:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Construct a piecewise polynomial from a spline

Parameters ---------- tck A spline, as returned by `splrep` or a BSpline object. 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:[ `Bool of bool | `Periodic ] -> a:float -> b:float -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.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 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), use `self.extrapolate`.

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

val roots : ?discontinuity:bool -> ?extrapolate:[ `Bool of bool | `Periodic ] -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Find real roots of the the piecewise polynomial.

Parameters ---------- discontinuity : bool, optional Whether to report sign changes across discontinuities at breakpoints as roots. extrapolate : ool, 'periodic', None, optional If bool, determines whether to return roots from the polynomial extrapolated based on first and last intervals, 'periodic' works the same as False. If None (default), use `self.extrapolate`.

Returns ------- roots : ndarray Roots of the polynomial(s).

If the PPoly object describes multiple polynomials, the return value is an object array whose each element is an ndarray containing the roots.

See Also -------- PPoly.solve

val solve : ?y:float -> ?discontinuity:bool -> ?extrapolate:[ `Bool of bool | `Periodic ] -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Find real solutions of the the equation ``pp(x) == y``.

Parameters ---------- y : float, optional Right-hand side. Default is zero. discontinuity : bool, optional Whether to report sign changes across discontinuities at breakpoints as roots. extrapolate : ool, 'periodic', None, optional If bool, determines whether to return roots from the polynomial extrapolated based on first and last intervals, 'periodic' works the same as False. If None (default), use `self.extrapolate`.

Returns ------- roots : ndarray Roots of the polynomial(s).

If the PPoly object describes multiple polynomials, the return value is an object array whose each element is an ndarray containing the roots.

Notes ----- This routine works only on real-valued polynomials.

If the piecewise polynomial contains sections that are identically zero, the root list will contain the start point of the corresponding interval, followed by a ``nan`` value.

If the polynomial is discontinuous across a breakpoint, and there is a sign change across the breakpoint, this is reported if the `discont` parameter is True.

Examples --------

Finding roots of ``x**2 - 1, (x - 1)**2`` defined on intervals ``-2, 1, 1, 2``:

>>> from scipy.interpolate import PPoly >>> pp = PPoly(np.array([1, -4, 3], [1, 0, 0]).T, -2, 1, 2) >>> pp.solve() array(-1., 1.)

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 : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.