Hallo,
I am currently looking for a c++ algorithm which is able to fit a 2 dimensional non linear function. c[] coefficients are the needed output.
f(x,y) = c[0] * exp(-c[1]/x) * y^c[2].
In the the documentation of alglib it is mentioned that this would be possible (and I think gnuplot is using the alglib and is able to do multidimensional fitting). Here is the excerpt of the alglib docu:
Linear least squares
Most fitting algorithms implemented in ALGLIB are build on top of the linear least squares solver:
- Polynomial curve fitting (including linear fitting) - Rational curve fitting using Floater-Hormann basis - Spline curve fitting using penalized regression splines - And, finally, linear least squares fitting itself
First three methods are important special cases of the 1-dimensional curve fitting. Last method can be used for 1-dimensional or multidimensional fitting. ... to solve multidimensional problem, then you can use general linear or nonlinear least squares solver. These solvers can fit general form functions represented by basis matrix (LLS) or by callback which calculates function value at given point (NLS).
But when I look in the examples and lsfit functions only 1d arrays for f(x|c) can be defined and none 2d arrays for f(x,y|c). Can someone please give an example for multidimensional multivariate regression with the alglib (for example: given above or f(x,y) = ln x + y^0.5 or ...). No multidimensional fitting examples exists, when I was looking at least.
ps. I do not want to 'log' the function in order to create a polynomial function (spline), because f(x,y) is just a more simplified version which may consists of additional terms (ex.: f(x,y) = c[0] * exp(-c[1]/x) * c[1]/x * y^c[2] * y).
Thx in advance.
|