.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Polynomial 3pm" .TH Polynomial 3pm 2024-05-12 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME PDL::Fit::Polynomial \- routines for fitting with polynomials .SH DESCRIPTION .IX Header "DESCRIPTION" This module contains routines for doing simple polynomial fits to data .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& $yfit = fitpoly1d $data; .Ve .SH FUNCTIONS .IX Header "FUNCTIONS" .SS fitpoly1d .IX Subsection "fitpoly1d" Fit 1D polynomials to data using min chi^2 (least squares) .PP .Vb 1 \& Usage: ($yfit, [$coeffs]) = fitpoly1d [$xdata], $data, $order, [Options...] .Ve .PP .Vb 1 \& Signature: (x(n); y(n); [o]yfit(n); [o]coeffs(order)) .Ve .PP Uses a standard matrix inversion method to do a least squares/min chi^2 polynomial fit to data. Order=2 is a linear fit (two parameters). .PP Returns the fitted data and optionally the coefficients. .PP One can broadcast over extra dimensions to do multiple fits (except the order can not be broadcasted over \- i.e. it must be one fixed scalar number like "4"). .PP The data is normalised internally to avoid overflows (using the mean of the abs value) which are common in large polynomial series but the returned fit, coeffs are in unnormalised units. .PP .Vb 2 \& $yfit = fitpoly1d $data,2; # Least\-squares line fit \& ($yfit, $coeffs) = fitpoly1d $x, $y, 4; # Fit a cubic \& \& $fitimage = fitpoly1d $image,3 # Fit a quadratic to each row of an image \& \& $myfit = fitpoly1d $line, 2, {Weights => $w}; # Weighted fit .Ve .PP .Vb 2 \& Options: \& Weights Weights to use in fit, e.g. 1/$sigma**2 (default=1) .Ve .SH BUGS .IX Header "BUGS" May not work too well for data with large dynamic range. .SH "SEE ALSO" .IX Header "SEE ALSO" "polyfit" in PDL::Slatec .SH AUTHOR .IX Header "AUTHOR" This file copyright (C) 1999, Karl Glazebrook (kgb@aaoepp.aao.gov.au). All rights reserved. There is no warranty. You are allowed to redistribute this software documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file.