package np

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `Legendre
]
type t = [ `ABCPolyBase | `Legendre | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val as_abc_poly : t -> [ `ABCPolyBase ] Obj.t
val create : ?domain:Py.Object.t -> ?window:Py.Object.t -> coef:[> `Ndarray ] Obj.t -> unit -> t

A Legendre series class.

The Legendre class provides the standard Python numerical methods '+', '-', '*', '//', '%', 'divmod', '**', and '()' as well as the attributes and methods listed in the `ABCPolyBase` documentation.

Parameters ---------- coef : array_like Legendre coefficients in order of increasing degree, i.e., ``(1, 2, 3)`` gives ``1*P_0(x) + 2*P_1(x) + 3*P_2(x)``. domain : (2,) array_like, optional Domain to use. The interval ``domain[0], domain[1]`` is mapped to the interval ``window[0], window[1]`` by shifting and scaling. The default value is -1, 1. window : (2,) array_like, optional Window, see `domain` for its use. The default value is -1, 1.

.. versionadded:: 1.6.0

val __iter__ : [> tag ] Obj.t -> Py.Object.t

None

val basis : ?domain:[> `Ndarray ] Obj.t -> ?window:[> `Ndarray ] Obj.t -> deg:int -> [> tag ] Obj.t -> Py.Object.t

Series basis polynomial of degree `deg`.

Returns the series representing the basis polynomial of degree `deg`.

.. versionadded:: 1.7.0

Parameters ---------- deg : int Degree of the basis polynomial for the series. Must be >= 0. domain : None, array_like, optional If given, the array must be of the form ``beg, end``, where ``beg`` and ``end`` are the endpoints of the domain. If None is given then the class domain is used. The default is None. window : None, array_like, optional If given, the resulting array must be if the form ``beg, end``, where ``beg`` and ``end`` are the endpoints of the window. If None is given then the class window is used. The default is None.

Returns ------- new_series : series A series with the coefficient of the `deg` term set to one and all others zero.

val cast : ?domain:[> `Ndarray ] Obj.t -> ?window:[> `Ndarray ] Obj.t -> series:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Convert series to series of this class.

The `series` is expected to be an instance of some polynomial series of one of the types supported by by the numpy.polynomial module, but could be some other class that supports the convert method.

.. versionadded:: 1.7.0

Parameters ---------- series : series The series instance to be converted. domain : None, array_like, optional If given, the array must be of the form ``beg, end``, where ``beg`` and ``end`` are the endpoints of the domain. If None is given then the class domain is used. The default is None. window : None, array_like, optional If given, the resulting array must be if the form ``beg, end``, where ``beg`` and ``end`` are the endpoints of the window. If None is given then the class window is used. The default is None.

Returns ------- new_series : series A series of the same kind as the calling class and equal to `series` when evaluated.

See Also -------- convert : similar instance method

val convert : ?domain:[> `Ndarray ] Obj.t -> ?kind:Py.Object.t -> ?window:[> `Ndarray ] Obj.t -> [> tag ] Obj.t -> Py.Object.t

Convert series to a different kind and/or domain and/or window.

Parameters ---------- domain : array_like, optional The domain of the converted series. If the value is None, the default domain of `kind` is used. kind : class, optional The polynomial series type class to which the current instance should be converted. If kind is None, then the class of the current instance is used. window : array_like, optional The window of the converted series. If the value is None, the default window of `kind` is used.

Returns ------- new_series : series The returned class can be of different type than the current instance and/or have a different domain and/or different window.

Notes ----- Conversion between domains and class types can result in numerically ill defined series.

Examples --------

val copy : [> tag ] Obj.t -> Py.Object.t

Return a copy.

Returns ------- new_series : series Copy of self.

val cutdeg : deg:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Truncate series to the given degree.

Reduce the degree of the series to `deg` by discarding the high order terms. If `deg` is greater than the current degree a copy of the current series is returned. This can be useful in least squares where the coefficients of the high degree terms may be very small.

.. versionadded:: 1.5.0

Parameters ---------- deg : non-negative int The series is reduced to degree `deg` by discarding the high order terms. The value of `deg` must be a non-negative integer.

Returns ------- new_series : series New instance of series with reduced degree.

val degree : [> tag ] Obj.t -> int

The degree of the series.

.. versionadded:: 1.5.0

Returns ------- degree : int Degree of the series, one less than the number of coefficients.

val deriv : ?m:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Differentiate.

Return a series instance of that is the derivative of the current series.

Parameters ---------- m : non-negative int Find the derivative of order `m`.

Returns ------- new_series : series A new series representing the derivative. The domain is the same as the domain of the differentiated series.

val fit : ?domain:Py.Object.t -> ?rcond:float -> ?full:bool -> ?w:[> `Ndarray ] Obj.t -> ?window:Py.Object.t -> y:[> `Ndarray ] Obj.t -> deg:[ `T1_D_array_like of Py.Object.t | `I of int ] -> [> `Ndarray ] Obj.t -> [> tag ] Obj.t -> Py.Object.t

Least squares fit to data.

Return a series instance that is the least squares fit to the data `y` sampled at `x`. The domain of the returned instance can be specified and this will often result in a superior fit with less chance of ill conditioning.

Parameters ---------- x : array_like, shape (M,) x-coordinates of the M sample points ``(xi, yi)``. y : array_like, shape (M,) or (M, K) y-coordinates of the sample points. Several data sets of sample points sharing the same x-coordinates can be fitted at once by passing in a 2D-array that contains one dataset per column. deg : int or 1-D array_like Degree(s) of the fitting polynomials. If `deg` is a single integer all terms up to and including the `deg`'th term are included in the fit. For NumPy versions >= 1.11.0 a list of integers specifying the degrees of the terms to include may be used instead. domain : None, [beg, end], [], optional Domain to use for the returned series. If ``None``, then a minimal domain that covers the points `x` is chosen. If ```` the class domain is used. The default value was the class domain in NumPy 1.4 and ``None`` in later versions. The ```` option was added in numpy 1.5.0. rcond : float, optional Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases. full : bool, optional Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned. w : array_like, shape (M,), optional Weights. If not None the contribution of each point ``(xi,yi)`` to the fit is weighted by `wi`. Ideally the weights are chosen so that the errors of the products ``wi*yi`` all have the same variance. The default value is None.

.. versionadded:: 1.5.0 window :

beg, end

, optional Window to use for the returned series. The default value is the default class domain

.. versionadded:: 1.6.0

Returns ------- new_series : series A series that represents the least squares fit to the data and has the domain and window specified in the call. If the coefficients for the unscaled and unshifted basis polynomials are of interest, do ``new_series.convert().coef``.

resid, rank, sv, rcond : list These values are only returned if `full` = True

resid -- sum of squared residuals of the least squares fit rank -- the numerical rank of the scaled Vandermonde matrix sv -- singular values of the scaled Vandermonde matrix rcond -- value of `rcond`.

For more details, see `linalg.lstsq`.

val fromroots : ?domain:[ `Ndarray of [> `Ndarray ] Obj.t | `T_ of Py.Object.t | `None ] -> ?window:[> `Ndarray ] Obj.t -> roots:[> `Ndarray ] Obj.t -> [> tag ] Obj.t -> Py.Object.t

Return series instance that has the specified roots.

Returns a series representing the product ``(x - r0)*(x - r1)*...*(x - rn-1)``, where ``r`` is a list of roots.

Parameters ---------- roots : array_like List of roots. domain :

], None, array_like}, optional
    Domain for the resulting series. If None the domain is the
    interval from the smallest root to the largest. If [] the
    domain is the class domain. The default is [].
window : {None, array_like}, optional
    Window for the returned series. If None the class window is
    used. The default is None.

Returns
-------
new_series : series
    Series with the specified roots.
val has_samecoef : other:Py.Object.t -> [> tag ] Obj.t -> bool

Check if coefficients match.

.. versionadded:: 1.6.0

Parameters ---------- other : class instance The other class must have the ``coef`` attribute.

Returns ------- bool : boolean True if the coefficients are the same, False otherwise.

val has_samedomain : other:Py.Object.t -> [> tag ] Obj.t -> bool

Check if domains match.

.. versionadded:: 1.6.0

Parameters ---------- other : class instance The other class must have the ``domain`` attribute.

Returns ------- bool : boolean True if the domains are the same, False otherwise.

val has_sametype : other:Py.Object.t -> [> tag ] Obj.t -> bool

Check if types match.

.. versionadded:: 1.7.0

Parameters ---------- other : object Class instance.

Returns ------- bool : boolean True if other is same class as self

val has_samewindow : other:Py.Object.t -> [> tag ] Obj.t -> bool

Check if windows match.

.. versionadded:: 1.6.0

Parameters ---------- other : class instance The other class must have the ``window`` attribute.

Returns ------- bool : boolean True if the windows are the same, False otherwise.

val identity : ?domain:[> `Ndarray ] Obj.t -> ?window:[> `Ndarray ] Obj.t -> [> tag ] Obj.t -> Py.Object.t

Identity function.

If ``p`` is the returned series, then ``p(x) == x`` for all values of x.

Parameters ---------- domain : None, array_like, optional If given, the array must be of the form ``beg, end``, where ``beg`` and ``end`` are the endpoints of the domain. If None is given then the class domain is used. The default is None. window : None, array_like, optional If given, the resulting array must be if the form ``beg, end``, where ``beg`` and ``end`` are the endpoints of the window. If None is given then the class window is used. The default is None.

Returns ------- new_series : series Series of representing the identity.

val integ : ?m:Py.Object.t -> ?k:[> `Ndarray ] Obj.t -> ?lbnd:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Integrate.

Return a series instance that is the definite integral of the current series.

Parameters ---------- m : non-negative int The number of integrations to perform. k : array_like Integration constants. The first constant is applied to the first integration, the second to the second, and so on. The list of values must less than or equal to `m` in length and any missing values are set to zero. lbnd : Scalar The lower bound of the definite integral.

Returns ------- new_series : series A new series representing the integral. The domain is the same as the domain of the integrated series.

val linspace : ?n:int -> ?domain:[> `Ndarray ] Obj.t -> [> tag ] Obj.t -> Py.Object.t

Return x, y values at equally spaced points in domain.

Returns the x, y values at `n` linearly spaced points across the domain. Here y is the value of the polynomial at the points x. By default the domain is the same as that of the series instance. This method is intended mostly as a plotting aid.

.. versionadded:: 1.5.0

Parameters ---------- n : int, optional Number of point pairs to return. The default value is 100. domain : None, array_like, optional If not None, the specified domain is used instead of that of the calling instance. It should be of the form ``beg,end``. The default is None which case the class domain is used.

Returns ------- x, y : ndarray x is equal to linspace(self.domain0, self.domain1, n) and y is the series evaluated at element of x.

val mapparms : [> tag ] Obj.t -> Py.Object.t

Return the mapping parameters.

The returned values define a linear map ``off + scl*x`` that is applied to the input arguments before the series is evaluated. The map depends on the ``domain`` and ``window``; if the current ``domain`` is equal to the ``window`` the resulting map is the identity. If the coefficients of the series instance are to be used by themselves outside this class, then the linear function must be substituted for the ``x`` in the standard representation of the base polynomials.

Returns ------- off, scl : float or complex The mapping function is defined by ``off + scl*x``.

Notes ----- If the current domain is the interval ``l1, r1`` and the window is ``l2, r2``, then the linear mapping function ``L`` is defined by the equations::

L(l1) = l2 L(r1) = r2

val roots : [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Obj.t

Return the roots of the series polynomial.

Compute the roots for the series. Note that the accuracy of the roots decrease the further outside the domain they lie.

Returns ------- roots : ndarray Array containing the roots of the series.

val trim : ?tol:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Remove trailing coefficients

Remove trailing coefficients until a coefficient is reached whose absolute value greater than `tol` or the beginning of the series is reached. If all the coefficients would be removed the series is set to ``0``. A new series instance is returned with the new coefficients. The current instance remains unchanged.

Parameters ---------- tol : non-negative number. All trailing coefficients less than `tol` will be removed.

Returns ------- new_series : series Contains the new set of coefficients.

val truncate : size:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Truncate series to length `size`.

Reduce the series to length `size` by discarding the high degree terms. The value of `size` must be a positive integer. This can be useful in least squares where the coefficients of the high degree terms may be very small.

Parameters ---------- size : positive int The series is reduced to length `size` by discarding the high degree terms. The value of `size` must be a positive integer.

Returns ------- new_series : series New instance of series with truncated coefficients.

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.