Gaussian(3pm)
π PDL::Fit::Gaussian β the perl manpage, but make it a group chat π
okay bestie, gather round, because this is Gaussian(3pm) from the User Contributed Perl Documentation and it's about to be your new hyperfixation. we're talking gaussian fitting routines and we're talking them loudly. π¦
β¨ NAME β¨
PDL::Fit::Gaussian β routines for fitting gaussians π
πΈ DESCRIPTION πΈ
so this module is a little collection of custom gaussian fitting routines. they were developed in collab with Alison Offer (yes, a real one, we stan a co-author) and likeβ¦ they do a reasonably robust job and they're genuinely quite useful. no cap. π₯
gaussian fitting is something the author does a LOT of, so it was worth putting in their special code. main character energy honestly. β¨
β οΈ real talk warning: it is NOT clear that this code is fully debugged. the reason for that is that our author tried using the internal linear eqn solving C routines called elsewhere and they were giving erroneous results. so steal from this code with caution! however β and this is the slay part β it does give good fits to reasonable looking gaussians and tests show correct parameters. β¨
KGB 29/Oct/2002 π
β SYNOPSIS β
use PDL;
use PDL::Fit::Gaussian;
($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data);
($pk, $fwhm, $back, $err, $fit) = fitgauss1dr($r, $data);
look at that. two lines of loading, two lines of living. π
π FUNCTIONS π
fitgauss1d π§
Fit 1D Gassian to data ndarray
(yes it says "Gassian". that's the spelling. we love her. we protect her. π«Ά)
($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data);
($cen, $pk, $fwhm, $back, $err, $fit) = fitgauss1d($x, $data);
xval(n); data(n); [o]xcentre();[o]peak_ht(); [o]fwhm();
[o]background();int [o]err(); [o]datafit(n);
[t]sig(n); [t]ytmp(n); [t]yytmp(n); [t]rtmp(n);
okay so what does it actually do: it fits a 1D Gaussian robustly, and the free parameters are the centre, the peak height, and the FWHM. π
the background is NOT fit β because our author finds that generally unreliable β instead a median is determined in the 'outer' 10% of pixels (i.e. those at the start/end of the data ndarray). π
the initial estimate of the FWHM is the length of the ndarray/3, so it might fail if the ndarray is too long. (this is non-robust anyway, don't come for her). most data does just fine and this is a good default gaussian fitter. periodt. π
the values of the error code $err correspond to:
0β successful fit β1β internal problem with memory allocation π2β insufficient number of data points π3β fit did not converge π
SEE ALSO: fitgauss1dr() for fitting radial gaussians
fitgauss1dr π
Fit 1D Gassian to radial data ndarray
($pk, $fwhm2, $back, $err, $fit) = fitgauss1dr($r, $data);
($pk, $fwhm2, $back, $err, $fit) = fitgauss1dr($r, $data);
xval(n); data(n); [o]peak_ht(); [o]fwhm();
[o]background();int [o]err(); [o]datafit(n);
[t]sig(n); [t]ytmp(n); [t]yytmp(n); [t]rtmp(n);
this one fits a 1D radial Gaussian robustly, and the free parameters are the peak height and the FWHM. the centre is assumed to be X=0 (i.e. the start of the ndarray). no centre-finding here, she's already decided. π
the background is NOT fit β again, generally unreliable β instead a median is determined in the 'outer' 10% of pixels (i.e. those at the end of the data ndarray). β¨
the initial estimate of the FWHM is the length of the ndarray/3, so it might fail if the ndarray is too long. (non-robust anyway, we've been over this). most data does just fine and this is a good default gaussian fitter. π
the values of the error code $err correspond to:
0β successful fit β1β internal problem with memory allocation π2β insufficient number of data points π3β fit did not converge π
SEE ALSO: fitgauss1d() to fit centre as well.
π BUGS π
May not converge for weird data, still pretty good! π
(that's it. that's the whole bug section. she's confident, she's honest, she's iconic.)
π AUTHOR π
This file copyright (C) 1999, Karl Glazebrook (kgb@aaoepp.aao.gov.au), Gaussian fitting code by Alison Offer (aro@aaocbn.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. π
and that's the whole thing bestie, no notes, go fit some gaussians π¦β¨
signing off β this was perl v5.42.3, dated 2026-08-21, Gaussian(3pm), mwah π
π¦ where this page comes from
- ubuntu stonking: libpdl-fit-perl 2.101-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms