cupy.polyfit

cupy.polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False)[source]

Returns the least squares fit of polynomial of degree deg to the data y sampled at x.

Parameters
  • x (cupy.ndarray) – x-coordinates of the sample points of shape (M,).

  • y (cupy.ndarray) – y-coordinates of the sample points of shape (M,) or (M, K).

  • deg (int) – degree of the fitting polynomial.

  • rcond (float, optional) – relative condition number of the fit. The default value is len(x) * eps.

  • full (bool, optional) – indicator of the return value nature. When False (default), only the coefficients are returned. When True, diagnostic information is also returned.

  • w (cupy.ndarray, optional) – weights applied to the y-coordinates of the sample points of shape (M,).

  • cov (bool or str, optional) – if given, returns the coefficients along with the covariance matrix.

Returns

of shape (deg + 1,) or (deg + 1, K).

Polynomial coefficients from highest to lowest degree

tuple (cupy.ndarray, int, cupy.ndarray, float):

Present only if full=True. Sum of squared residuals of the least-squares fit, rank of the scaled Vandermonde coefficient matrix, its singular values, and the specified value of rcond.

cupy.ndarray: of shape (M, M) or (M, M, K).

Present only if full=False and cov=True. The covariance matrix of the polynomial coefficient estimates.

Return type

cupy.ndarray

Warning

numpy.RankWarning: The rank of the coefficient matrix in the least-squares fit is deficient. It is raised if full=False.

See also

numpy.polyfit()