Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

# PDL::Fit::LM 2.3.2

Date Added: October 15, 2010  |  Visits: 685

PDL::Fit::LM is a Levenber-Marquardt fitting routine for PDL. Currently, only Levenberg-Marquardt fitting is implemented. Other procedures should be added as required. For a fairly concise overview on fitting see Numerical Recipes, chapter 15 "Modeling of data". SYNOPSIS use PDL::Fit::LM; \$ym = lmfit \$x, \$y, \$sig, &expfunc, \$a, {Maxiter => 300}; FUNCTIONS lmfit Levenberg-Marquardt fitting of a user supplied model function (\$ym,\$a,\$covar,\$iters) = lmfit \$x, \$y, \$sig, &expfunc, \$a, {Maxiter => 300, Eps => 1e-3}; Options: Maxiter: maximum number of iterations before giving up Eps: convergence citerium for fit; success when normalized change in chisquare smaller than Eps The user supplied sub routine reference should accept 4 arguments a vector of independent values \$x a vector of fitting parameters a vector of dependent variables that will be assigned upon return a matrix of partial derivatives with respect to the fitting parameters that will be assigned upon return As an example take this definition of a single exponential with 3 parameters (width, amplitude, offset): sub expdec { my (\$x,\$par,\$ym,\$dyda) = @_; my (\$a,\$b,\$c) = map {\$par->slice("(\$_)")} (0..2); my \$arg = \$x/\$a; my \$ex = exp(\$arg); \$ym .= \$b*\$ex+\$c; my (@dy) = map {\$dyda->slice(",(\$_)")} (0..2); \$dy[0] .= -\$b*\$ex*\$arg/\$a; \$dy[1] .= \$ex; \$dy[2] .= 1; } Note usage of the .= operator for assignment In scalar context returns a vector of the fitted dependent variable. In list context returns fitted y-values, vector of fitted parameters, an estimate of the covariance matrix (as an indicator of goodness of fit) and number of iterations performed. tlmfit threaded version of Levenberg-Marquardt fitting routine mfit tlmfit \$x, \$y, float(1)->dummy(0), \$na, float(200), float(1e-4), \$ym=null, \$afit=null, &expdec; Signature: tlmfit(x(n);y(n);sig(n);a(m);iter();eps();[o] ym(n);[o] ao(m); OtherPar => subref) a threaded version of lmfit by using perl threading. Direct threading in lmfit seemed difficult since we have an if condition in the iteration. In principle that can be worked around by using where but .... Send a threaded lmfit version if you work it out! Since we are using perl threading here speed is not really great but it is just convenient to have a threaded version for many applications (no explicit for-loops required, etc). Suffers from some of the current limitations of perl level threading..

 Requirements: No special requirements Platforms: Linux Keyword: Fitting,  Libraries,  Lm,  Pdl,  Pdlfitlm,  Programming,  Routine,  Vector,  Ym Users rating: 0/10