Least squares fit of Hermite series to data. Return the coefficients of a Hermite series of degree `deg` that is the least squares fit to the data values `y` given at points `x`. If `y` is 1-D the returned coefficients will also be 1-D. If `y` is 2-D multiple fits are done, one
(x, y, deg, rcond=None, full=False, w=None)
| 1354 | |
| 1355 | |
| 1356 | def hermfit(x, y, deg, rcond=None, full=False, w=None): |
| 1357 | """ |
| 1358 | Least squares fit of Hermite series to data. |
| 1359 | |
| 1360 | Return the coefficients of a Hermite series of degree `deg` that is the |
| 1361 | least squares fit to the data values `y` given at points `x`. If `y` is |
| 1362 | 1-D the returned coefficients will also be 1-D. If `y` is 2-D multiple |
| 1363 | fits are done, one for each column of `y`, and the resulting |
| 1364 | coefficients are stored in the corresponding columns of a 2-D return. |
| 1365 | The fitted polynomial(s) are in the form |
| 1366 | |
| 1367 | .. math:: p(x) = c_0 + c_1 * H_1(x) + ... + c_n * H_n(x), |
| 1368 | |
| 1369 | where `n` is `deg`. |
| 1370 | |
| 1371 | Parameters |
| 1372 | ---------- |
| 1373 | x : array_like, shape (M,) |
| 1374 | x-coordinates of the M sample points ``(x[i], y[i])``. |
| 1375 | y : array_like, shape (M,) or (M, K) |
| 1376 | y-coordinates of the sample points. Several data sets of sample |
| 1377 | points sharing the same x-coordinates can be fitted at once by |
| 1378 | passing in a 2D-array that contains one dataset per column. |
| 1379 | deg : int or 1-D array_like |
| 1380 | Degree(s) of the fitting polynomials. If `deg` is a single integer |
| 1381 | all terms up to and including the `deg`'th term are included in the |
| 1382 | fit. For NumPy versions >= 1.11.0 a list of integers specifying the |
| 1383 | degrees of the terms to include may be used instead. |
| 1384 | rcond : float, optional |
| 1385 | Relative condition number of the fit. Singular values smaller than |
| 1386 | this relative to the largest singular value will be ignored. The |
| 1387 | default value is len(x)*eps, where eps is the relative precision of |
| 1388 | the float type, about 2e-16 in most cases. |
| 1389 | full : bool, optional |
| 1390 | Switch determining nature of return value. When it is False (the |
| 1391 | default) just the coefficients are returned, when True diagnostic |
| 1392 | information from the singular value decomposition is also returned. |
| 1393 | w : array_like, shape (`M`,), optional |
| 1394 | Weights. If not None, the weight ``w[i]`` applies to the unsquared |
| 1395 | residual ``y[i] - y_hat[i]`` at ``x[i]``. Ideally the weights are |
| 1396 | chosen so that the errors of the products ``w[i]*y[i]`` all have the |
| 1397 | same variance. When using inverse-variance weighting, use |
| 1398 | ``w[i] = 1/sigma(y[i])``. The default value is None. |
| 1399 | |
| 1400 | Returns |
| 1401 | ------- |
| 1402 | coef : ndarray, shape (M,) or (M, K) |
| 1403 | Hermite coefficients ordered from low to high. If `y` was 2-D, |
| 1404 | the coefficients for the data in column k of `y` are in column |
| 1405 | `k`. |
| 1406 | |
| 1407 | [residuals, rank, singular_values, rcond] : list |
| 1408 | These values are only returned if ``full == True`` |
| 1409 | |
| 1410 | - residuals -- sum of squared residuals of the least squares fit |
| 1411 | - rank -- the numerical rank of the scaled Vandermonde matrix |
| 1412 | - singular_values -- singular values of the scaled Vandermonde matrix |
| 1413 | - rcond -- value of `rcond`. |
nothing calls this directly
no test coverage detected
searching dependent graphs…