claudejrogers / CBLAS-LM-Solver

Levenberg-Marquardt algorithm implemented in Objective-C
4 stars 2 forks source link

question #1

Closed avnerbarr closed 11 years ago

avnerbarr commented 11 years ago

How can i add a customized error function?

claudejrogers commented 11 years ago

Do you mean you want to fit data to an equation of the form erf(x)=\frac{2}{\sqrt{\pi}}\int^{x}_{0}e^{-z^{2}}dz, or something similar?

avnerbarr commented 11 years ago

I have a graph and I want to solve for points : the form of the minimization I am trying to solve for is as follows:

E(q1,q2,...qn) = SIGMA(e i,j) [ a(i,j) ( || qi -q j|| ^2 - dij)^2]

where qi's are the coordinates (x,y) e(i,j) are the edge from qi to qj and a(i,j) , d(i,j) are empericil values.

claudejrogers commented 11 years ago

I might not understand you correctly, so forgive me if this doesn't answer the question. This program doesn't provide a general minimization algorithm, but instead attempts to solve a very specific least squares problem:

minimize || f ( x ) ||, or equivalently find x* = argmin_x{F( x )}, where (in latex)

F(\mathbf{x}) = \frac{1}{2}\sum_{i = 1}^{m}(f_i(\mathbf{x}))^2 = \frac{1}{2}||\mathbf{f}(\mathbf{x})|| = \frac{1}{2}\mathbf{f}(\mathbf{x})^\top\mathbf{f}(\mathbf{x})

and

f_i(\mathbf{x}) = m_i(\mathbf{x}, t) - y_i

In other words, if one has a model equation m( x, t) that is expected to fit to data y, this program tries to find values for the parameters given in x to minimize the sum of squares of the residuals for each data point. The algorithm assumes that f has continuous second partial derivatives. Changing the form of F( x ) would probably require rewriting the program.

avnerbarr commented 11 years ago

ok. so in other words only the supplied functions will work? (in the big case statement) I'm looking for a general least squares solver for ios/mac if you know of one.

On Oct 28, 2012, at 10:28 PM, claudejrogers notifications@github.com wrote:

I might not understand you correctly, so forgive me if this doesn't answer the question. This program doesn't provide a general minimization algorithm, but instead attempts to solve a very specific least squares problem:

minimize || f ( x ) ||, or equivalently find x* = argmin_x{F( x )}, where (in latex)

F(\mathbf{x}) = \frac{1}{2}\sum_{i = 1}^{m}(f_i(\mathbf{x}))^2 = \frac{1}{2}||\mathbf{f}(\mathbf{x})|| = \frac{1}{2}\mathbf{f}(\mathbf{x})^\top\mathbf{f}(\mathbf{x}) and

f_i(\mathbf{x}) = m_i(\mathbf{x}, t) - y_i In other words, if one has a model equation m( x, t) that is expected to fit to data y, this program tries to find values for the parameters given in x to minimize the sum of squares of the residuals for each data point. The algorithm assumes that f has continuous second partial derivatives. Changing the form of F( x ) would probably require rewriting the program.

— Reply to this email directly or view it on GitHub.

claudejrogers commented 11 years ago

Oh, sorry, I did misunderstand you. Yes, you can add additional functions. I'll update the readme with instructions shortly.

You are talking about changing m(x, t), which is fine.

claudejrogers commented 11 years ago

Ok, I updated the readme. Let me know if you have additional questions.