1Polynomial(3) User Contributed Perl Documentation Polynomial(3)
2
3
4
6 PDL::Fit::Polynomial - routines for fitting with polynomials
7
9 This module contains routines for doing simple polynomial fits to data
10
12 $yfit = fitpoly1d $data;
13
15 fitpoly1d
16 Fit 1D polynomials to data using min chi^2 (least squares)
17
18 Usage: ($yfit, [$coeffs]) = fitpoly1d [$xdata], $data, $order, [Options...]
19
20 Signature: (x(n); y(n); [o]yfit(n); [o]coeffs(order))
21
22 Uses a standard matrix inversion method to do a least squares/min chi^2
23 polynomial fit to data. Order=2 is a linear fit (two parameters).
24
25 Returns the fitted data and optionally the coefficients.
26
27 One can broadcast over extra dimensions to do multiple fits (except the
28 order can not be broadcasted over - i.e. it must be one fixed scalar
29 number like "4").
30
31 The data is normalised internally to avoid overflows (using the mean of
32 the abs value) which are common in large polynomial series but the
33 returned fit, coeffs are in unnormalised units.
34
35 $yfit = fitpoly1d $data,2; # Least-squares line fit
36 ($yfit, $coeffs) = fitpoly1d $x, $y, 4; # Fit a cubic
37
38 $fitimage = fitpoly1d $image,3 # Fit a quadratic to each row of an image
39
40 $myfit = fitpoly1d $line, 2, {Weights => $w}; # Weighted fit
41
42 Options:
43 Weights Weights to use in fit, e.g. 1/$sigma**2 (default=1)
44
46 May not work too well for data with large dynamic range.
47
49 "polyfit" in PDL::Slatec
50
52 This file copyright (C) 1999, Karl Glazebrook (kgb@aaoepp.aao.gov.au).
53 All rights reserved. There is no warranty. You are allowed to
54 redistribute this software documentation under certain conditions. For
55 details, see the file COPYING in the PDL distribution. If this file is
56 separated from the PDL distribution, the copyright notice should be
57 included in the file.
58
59
60
61perl v5.38.0 2023-07-21 Polynomial(3)