![]() Registered Member ![]()
|
Hi,
can the Levenberg-Marquart (or nonlinear optimization) module of Eigen be used in 3 dimension (surface fitting)? All of its examples are in 2d. But I have to fit a surface and I don't know how to do that. I have a set of experimental data, which are function of two independent variable. So the matrices would not be the same, dimensionally. It's a very urgent case. Please help. |
![]() Moderator ![]()
|
Of course, the LevenbergMarquardt can be used in any dimension! Which kind of mathematical model do you wanna fit?
|
![]() Registered Member ![]()
|
I have a set of data, which are function of two independent vaiables "phi" and "theta". I want to fit a surface, which is a simple multiplication of two Gaussian function:
psi = [1/(S_phi*sqrt(2*pi))*exp(-0.5*((phi-phi_m)/S_phi)^2)] * [1/(S_theta*sqrt(2*pi))*exp(-0.5*((theta-theta_m)/S_theta)^2)]. The unknown parameters are "S_phi" and "S_theta". |
![]() Moderator ![]()
|
hm, why not simply computing the value of the variances from the variances of the data?
Anyway, using LM for that model is direct, you simply have to write a functor filling the value vector with psi(phi,theta) evaluated at each sample, and the Jacobian matrix containing the partial derivatives of psi(phi,theta) wrt psi and theta for each sample. |
![]() Registered Member ![]()
|
in 3d the psi is no more vector, it's a matrix. Is it okay, if I define it as a matrix?
|
![]() Moderator ![]()
|
Regardless of the physical dimension of your problem, at the end you're minimizing a sum of square terms "sum_i ( f_i(x_1,...,x_n) )^2". The functor you have to provide simply fill a 1D vector with values f_i evaluated for the current unknown values x_j...
|
![]() Registered Member ![]()
|
I've tried to convert it to a 1D vector, but its impossible. Actually the summation, which I have, ist not only over "i", but also over "j", because the variables "phi" and "theta" are independent.
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]