hmatrix-0.15.2.0: Linear algebra and numerical computation

Portabilityuses ffi
Stabilityprovisional
MaintainerAlberto Ruiz (aruiz at um dot es)
Safe HaskellNone

Numeric.GSL.Fitting

Contents

Description

Nonlinear Least-Squares Fitting

http://www.gnu.org/software/gsl/manual/html_node/Nonlinear-Least_002dSquares-Fitting.html

The example program in the GSL manual (see examples/fitting.hs):

dat = [
 ([0.0],([6.0133918608118675],0.1)),
 ([1.0],([5.5153769909966535],0.1)),
 ([2.0],([5.261094606015287],0.1)),
 ...
 ([39.0],([1.0619821710802808],0.1))]

expModel [a,lambda,b] [t] = [a * exp (-lambda * t) + b]

expModelDer [a,lambda,b] [t] = [[exp (-lambda * t), -t * a * exp(-lambda*t) , 1]]

(sol,path) = fitModelScaled 1E-4 1E-4 20 (expModel, expModelDer) dat [1,0,0]

> path
(6><5)
 [ 1.0,  76.45780563978782, 1.6465931240727802, 1.8147715267618197e-2, 0.6465931240727797
 , 2.0, 37.683816318260355,  2.858760367632973,  8.092094813253975e-2, 1.4479636296208662
 , 3.0,    9.5807893736187,  4.948995119561291,   0.11942927999921617, 1.0945766509238248
 , 4.0,  5.630494933603935,  5.021755718065913,   0.10287787128056883, 1.0338835440862608
 , 5.0,  5.443976278682909,  5.045204331329302,   0.10405523433131504,  1.019416067207375
 , 6.0, 5.4439736648994685,  5.045357818922331,   0.10404905846029407, 1.0192487112786812 ]
> sol
[(5.045357818922331,6.027976702418132e-2),
(0.10404905846029407,3.157045047172834e-3),
(1.0192487112786812,3.782067731353722e-2)]

Synopsis

Levenberg-Marquardt

nlFittingSource

Arguments

:: FittingMethod 
-> Double

absolute tolerance

-> Double

relative tolerance

-> Int

maximum number of iterations allowed

-> (Vector Double -> Vector Double)

function to be minimized

-> (Vector Double -> Matrix Double)

Jacobian

-> Vector Double

starting point

-> (Vector Double, Matrix Double)

solution vector and optimization path

Nonlinear multidimensional least-squares fitting.

data FittingMethod Source

Constructors

LevenbergMarquardtScaled

Interface to gsl_multifit_fdfsolver_lmsder. This is a robust and efficient version of the Levenberg-Marquardt algorithm as implemented in the scaled lmder routine in minpack. Minpack was written by Jorge J. More, Burton S. Garbow and Kenneth E. Hillstrom.

LevenbergMarquardt

This is an unscaled version of the lmder algorithm. The elements of the diagonal scaling matrix D are set to 1. This algorithm may be useful in circumstances where the scaled version of lmder converges too slowly, or the function is already scaled appropriately.

Utilities

fitModelScaledSource

Arguments

:: Double

absolute tolerance

-> Double

relative tolerance

-> Int

maximum number of iterations allowed

-> ([Double] -> x -> [Double], [Double] -> x -> [[Double]])

(model, derivatives)

-> [(x, ([Double], Double))]

instances

-> [Double]

starting point

-> ([(Double, Double)], Matrix Double)

(solution, error) and optimization path

Higher level interface to nlFitting LevenbergMarquardtScaled. The optimization function and Jacobian are automatically built from a model f vs x = y and its derivatives, and a list of instances (x, (y,sigma)) to be fitted.

fitModelSource

Arguments

:: Double

absolute tolerance

-> Double

relative tolerance

-> Int

maximum number of iterations allowed

-> ([Double] -> x -> [Double], [Double] -> x -> [[Double]])

(model, derivatives)

-> [(x, [Double])]

instances

-> [Double]

starting point

-> ([Double], Matrix Double)

solution and optimization path

Higher level interface to nlFitting LevenbergMarquardt. The optimization function and Jacobian are automatically built from a model f vs x = y and its derivatives, and a list of instances (x,y) to be fitted.