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