package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `KroghInterpolator
]
type t = [ `KroghInterpolator | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val create : ?axis:int -> xi:[ `Ndarray of [> `Ndarray ] Np.Obj.t | `Length_N of Py.Object.t ] -> yi:[> `Ndarray ] Np.Obj.t -> unit -> t

Interpolating polynomial for a set of points.

The polynomial passes through all the pairs (xi,yi). One may additionally specify a number of derivatives at each point xi; this is done by repeating the value xi and specifying the derivatives as successive yi values.

Allows evaluation of the polynomial and all its derivatives. For reasons of numerical stability, this function does not compute the coefficients of the polynomial, although they can be obtained by evaluating all the derivatives.

Parameters ---------- xi : array_like, length N Known x-coordinates. Must be sorted in increasing order. yi : array_like Known y-coordinates. When an xi occurs two or more times in a row, the corresponding yi's represent derivative values. axis : int, optional Axis in the yi array corresponding to the x-coordinate values.

Notes ----- Be aware that the algorithms implemented here are not necessarily the most numerically stable known. Moreover, even in a world of exact computation, unless the x coordinates are chosen very carefully - Chebyshev zeros (e.g. cos(i*pi/n)) are a good choice - polynomial interpolation itself is a very ill-conditioned process due to the Runge phenomenon. In general, even with well-chosen x values, degrees higher than about thirty cause problems with numerical instability in this code.

Based on 1_.

References ---------- .. 1 Krogh, 'Efficient Algorithms for Polynomial Interpolation and Numerical Differentiation', 1970.

Examples -------- To produce a polynomial that is zero at 0 and 1 and has derivative 2 at 0, call

>>> from scipy.interpolate import KroghInterpolator >>> KroghInterpolator(0,0,1,0,2,0)

This constructs the quadratic 2*X**2-2*X. The derivative condition is indicated by the repeated zero in the xi array; the corresponding yi values are 0, the function value, and 2, the derivative value.

For another example, given xi, yi, and a derivative ypi for each point, appropriate arrays can be constructed as:

>>> xi = np.linspace(0, 1, 5) >>> yi, ypi = np.random.rand(2, 5) >>> xi_k, yi_k = np.repeat(xi, 2), np.ravel(np.dstack((yi,ypi))) >>> KroghInterpolator(xi_k, yi_k)

To produce a vector-valued polynomial, supply a higher-dimensional array for yi:

>>> KroghInterpolator(0,1,[2,3],[4,5])

This constructs a linear polynomial giving (2,3) at 0 and (4,5) at 1.

val derivative : ?der:int -> x:[> `Ndarray ] Np.Obj.t -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Evaluate one derivative of the polynomial at the point x

Parameters ---------- x : array_like Point or points at which to evaluate the derivatives

der : integer, optional Which derivative to extract. This number includes the function value as 0th derivative.

Returns ------- d : ndarray Derivative interpolated at the x-points. Shape of d is determined by replacing the interpolation axis in the original array with the shape of x.

Notes ----- This is computed by evaluating all derivatives up to the desired one (using self.derivatives()) and then discarding the rest.

val derivatives : ?der:int -> x:[> `Ndarray ] Np.Obj.t -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Evaluate many derivatives of the polynomial at the point x

Produce an array of all derivative values at the point x.

Parameters ---------- x : array_like Point or points at which to evaluate the derivatives der : int or None, optional How many derivatives to extract; None for all potentially nonzero derivatives (that is a number equal to the number of points). This number includes the function value as 0th derivative.

Returns ------- d : ndarray Array with derivatives; dj contains the j-th derivative. Shape of dj is determined by replacing the interpolation axis in the original array with the shape of x.

Examples -------- >>> from scipy.interpolate import KroghInterpolator >>> KroghInterpolator(0,0,0,1,2,3).derivatives(0) array(1.0,2.0,3.0) >>> KroghInterpolator(0,0,0,1,2,3).derivatives(0,0) array([1.0,1.0], [2.0,2.0], [3.0,3.0])

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.