Math::...ultifit(3pm)
π NAME π
Math::GSL::Multifit β least-squares functions for a general linear model with multiple parameters. The page itself is filed as Math::...ultifit(3pm), sitting pretty under "User Contributed Perl Documentation", and it's giving very much math girlie goes brrr. π
π SYNOPSIS π
use Math::GSL::Multifit qw /:all/;
π¦ DESCRIPTION π¦
β οΈ okay so FIRST THING, bestie: NOTE: This module requires GSL 2.1 or higher. No GSL 2.1, no vibes. Periodt.
The functions in this module perform least-squares fits to a general linear model, y = X c where y is a vector of n observations, X is an n by p matrix of predictor variables, and the elements of the vector c are the p unknown best-fit parameters which are to be estimated. Like, it finds the c that makes your model β¨make senseβ¨.
Here is a list of all the functions in this module π :
gsl_multifit_linear_alloc($n, $p)β allocates a workspace for fitting a model to$nobservations using$pparameters. It's the little prep-your-station moment before the actual fit. π§gsl_multifit_linear_free($work)β frees the memory associated with the workspacew. Clean up after yourself, queen. π§Ήgsl_multifit_linear($X, $y, $c, $cov, $work)β computes the best-fit parameters vector$cof the modely = X cfor the observations vector$yand the matrix of predictor variables$X. The variance-covariance matrix of the model parameters vector$covis estimated from the scatter of the observations about the best-fit. The sum of squares of the residuals from the best-fit,\chi^2, is returned after0if the operation succeeded,1otherwise. If the coefficient of determination is desired, it can be computed from the expressionR^2 = 1 - \chi^2 / TSS, where the total sum of squares (TSS) of the observationsymay be computed fromgsl_stats_tss. The best-fit is found by singular value decomposition of the matrix$Xusing the preallocated workspace provided in$work. The modified Golub-Reinsch SVD algorithm is used, with column scaling to improve the accuracy of the singular values. Any components which have zero singular value (to machine precision) are discarded from the fit. Bu-bye, useless components. πgsl_multifit_linear_svd($X, $y, $tol, $c, $cov, $work)β computes the best-fit parameterscof the modely = X cfor the observations vector$yand the matrix of predictor variables$X. The variance-covariance matrix of the model parameters vector$covis estimated from the scatter of the observations about the best-fit. The sum of squares of the residuals from the best-fit,\chi^2, is returned after0if the operation succeeded,1otherwise. If the coefficient of determination is desired, it can be computed from the expressionR^2 = 1 - \chi^2 / TSS, where the total sum of squares (TSS) of the observationsymay be computed fromgsl_stats_tss. In this second form of the function the components are discarded if the ratio of singular valuess_i/s_0falls below the user-specified tolerance$tol, and the effective rank is returned after the sum of squares of the residuals from the best-fit. So you get to choose your own tolerance, main character move fr. π₯gsl_multifit_wlinear($X, $w, $y, $c, $cov, $workβ computes the best-fit parameters vector$cof the weighted modely = X cfor the observationsywith weights$wand the matrix of predictor variables$X. The covariance matrix of the model parameters$covis computed with the given weights. The weighted sum of squares of the residuals from the best-fit,\chi^2, is returned after0if the operation succeeded,1otherwise. If the coefficient of determination is desired, it can be computed from the expressionR^2 = 1 - \chi^2 / WTSS, where the weighted total sum of squares (WTSS) of the observationsymay be computed fromgsl_stats_wtss. The best-fit is found by singular value decomposition of the matrix$Xusing the preallocated workspace provided in$work. Any components which have zero singular value (to machine precision) are discarded from the fit. Weights = giving every observation the attention it deserves. πgsl_multifit_wlinear_svd($X, $w, $y, $tol, $rank, $c, $cov, $work)β this function computes the best-fit parameters vector$cof the weighted modely = X cfor the observationsywith weights$wand the matrix of predictor variables$X. The covariance matrix of the model parameters$covis computed with the given weights. The weighted sum of squares of the residuals from the best-fit,\chi^2, is returned after0if the operation succeeded,1otherwise. If the coefficient of determination is desired, it can be computed from the expressionR^2 = 1 - \chi^2 / WTSS, where the weighted total sum of squares (WTSS) of the observationsymay be computed fromgsl_stats_wtss. The best-fit is found by singular value decomposition of the matrix$Xusing the preallocated workspace provided in$work. In this second form of the function the components are discarded if the ratio of singular valuess_i/s_0falls below the user-specified tolerance$tol, and the effective rank is returned after the sum of squares of the residuals from the best-fit. It's the SVD edition of the weighted one, and it ate. πgsl_multifit_linear_est($x, $c, $cov)β uses the best-fit multilinear regression coefficients vector$cand their covariance matrix$covto compute the fitted function value$yand its standard deviation$y_errfor the modely = x.cat the point$x, in the form of a vector. The function returns 3 values in this order:0if the operation succeeded,1otherwise, the fitted function value and its standard deviation. Three little returns, one iconic trio. β¨gsl_multifit_linear_residuals($X, $y, $c, $r)β computes the vector of residualsr = y - X cfor the observations vector$y, coefficients vector$cand matrix of predictor variables$X.$ris also a vector. That's the "how wrong were we" vector, and honestly? relatable. πgsl_multifit_gradient($J, $f, $g)β computes the gradient$gof\Phi(x) = (1/2) ||F(x)||^2from the Jacobian matrix$Jand the function values$f, using the formula$g = $J^T $f.$gand$fare vectors.gsl_multifit_test_gradient($g, $epsabas)β tests the residual gradient vector$gagainst the absolute error bound$epsabs. Mathematically, the gradient should be exactly zero at the minimum. The test returns$GSL_SUCCESSif the following condition is achieved:\sum_i |g_i| < $epsabs, and returns$GSL_CONTINUEotherwise. This criterion is suitable for situations where the precise location of the minimum,x, is unimportant provided a value can be found where the gradient is small enough. Close enough is sometimes enough, bestie. πgsl_multifit_test_delta($dx, $x, $epsabs, $epsrel)β tests for the convergence of the sequence by comparing the last step vector$dxwith the absolute error$epsabsand relative error$epsrelto the current positionx. The test returns$GSL_SUCCESSif the following condition is achieved:|dx_i| < epsabs + epsrel |x_i|for each component ofx, and returns$GSL_CONTINUEotherwise. It's the vibe check for "are we there yet". π
The following functions are not yet implemented. Patches Welcome! (open invitation, bestie, the door is OPEN π«Ά)
gsl_multifit_covargsl_multifit_fsolver_alloc($T, $n, $p)gsl_multifit_fsolver_freegsl_multifit_fsolver_setgsl_multifit_fsolver_iterategsl_multifit_fsolver_namegsl_multifit_fsolver_positiongsl_multifit_fdfsolver_allocgsl_multifit_fdfsolver_setgsl_multifit_fdfsolver_iterategsl_multifit_fdfsolver_freegsl_multifit_fdfsolver_namegsl_multifit_fdfsolver_position
For more information on the functions, we refer you to the GSL official documentation: <http://www.gnu.org/software/gsl/manual/html_node/> π
π EXAMPLES π
(This section is empty in the original β literally nothing here, not a single example. The blank space is giving mysterious, honestly. π«₯)
π AUTHORS π
Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com> β the icons who wrote this. Bow. πββοΈ
π COPYRIGHT AND LICENSE π
Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
And that's the whole page, bestie β brought to you by perl v5.42.3, dated 2026-08-20, and filed as Math::...ultifit(3pm). Go fit your model, you absolute legend. π
πβ¨
π¦ where this page comes from
- ubuntu stonking: libmath-gsl-perl 0.49-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