.\" Automatically generated by Pod::Man 4.14 (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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 "2023-06-17" "perl v5.36.0" "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 \*(L"4\*(R"). .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" \&\*(L"polyfit\*(R" 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 \&\s-1COPYING\s0 in the \s-1PDL\s0 distribution. If this file is separated from the \&\s-1PDL\s0 distribution, the copyright notice should be included in the file.