
From:  Patrick Alken 
Subject:  Re: [Helpgsl] Multidimensional leastsquarefit sought 
Date:  Thu, 09 Jan 2014 11:06:50 0700 
Useragent:  Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 
On 01/09/2014 10:45 AM, Matthias Sitte wrote:
On 01/09/2014 11:22 AM, Patrick Alken wrote:You'll want to use the gsl_multifit_linear or gsl_multifit_robust routines in Least Squares > multi parameter fitting part of the manual. You need to build the least squares matrix manually and then pass it to those routines.Ok, so solve y = X.c I use c=(c00, c10, c01, c20, c11, c02) and for each data point (px,py,pz) I add a line to the matrix X with (1, px, py, px*px, px*py, py*py) and a line the vector y with value pz, right? Finally, I end up with a linear matrixvector equation, where y has (possibly) large number N of rows, X is an Nby6 matrix, and the result is a coefficient vector of length 6, right? Plus I get the 6by6 covariance matrix and the chi^2. If so, that's way easier than I thought, but it's GSL 8) Nice interface! Thx! Matthias
Yes that's correct. If you have a lot of noise/outliers in your dataset try the robust fitting routine, otherwise the linear/ordinary least squares routine will work fine.
On 01/09/2014 10:15 AM, Matthias Sitte wrote:Hi, I'm looking for a way to to a leastsquarefit to a data set (x,y,z). The fit function should be a polynomal like the following: z(x,y) = \sum_{m,n=0,m+n<=N}^{N} c_{mn} x^m y^n = c_{00} + c_{10} x + c_{01} y + c_{20} x^2 + c_{11} xy + c_{02} y^2 + ... I've been using GSL a lot and know my way around, but I don't know the terminology of leastsquarefits, so I'm kindly asking you to name the proper function(s) I should use before I lose myself in the docs ;) Thx, Matthias
[Prev in Thread]  Current Thread  [Next in Thread] 