I am looking for a C# implementation of the Levenberg–Marquardt algorithm for non-linear least squares fit.
Asked
Active
Viewed 1.6k times
3 Answers
7
Levenberg-Marquardt.NET by Krzysztof Kniaz has worked very well for me.

demongolem
- 9,474
- 36
- 90
- 105

Craig W
- 4,390
- 5
- 33
- 51
-
Thanks! I had a look at it a while ago, I couldnt get it to work when I had several input and output parameters for each data point. – HaMo Feb 03 '12 at 12:08
-
Thanks! I had a look at it a while ago, I couldnt get it to work when I had several input and output parameters for each data point. Basically I have 3-D input coordinates and 3-D output coordinates, and 3-D reference coordinates for each data point. The 12 parameter function is supposed to make the output equal to the reference value for each point. Thus I calculate the norm of the error (reference value - output value) for each data point in the set as the function I want to minimize. I wasnt able to rewrite the code so that it achieved this. – HaMo Feb 03 '12 at 12:14
-
Instead I use a robust c++ program and a c++ to c# wrapper function. – HaMo Feb 03 '12 at 12:15
-
Sorry that library did not work for you but good to hear you found a way to do it. Do you mind sharing which C++ library you used? Have you considered trying to port it to C#? Not worth the effort or are you concerned about speed? – Craig W Feb 03 '12 at 17:35
-
http://joachimwuttke.de/lmfit/index.html the library is in c. the quick and dirty solution i did was to compile the source code as a c++ project, and create a dll that could be executed from c#, using DllExport() / DllImport() – HaMo Feb 07 '12 at 08:52
-
I moved the lmfit repository to http://apps.jcns.fz-juelich.de/lmfit. – Joachim W Dec 02 '15 at 17:27
-
http://apps.jcns.fz-juelich.de/src/lmfit/lmfit-6.1.tgz – Pitka Dec 08 '16 at 08:32
6
You might want to try csmpfit. It is open source.
Update:
The project has been moved to GitHub at https://github.com/cureos/csmpfit.

Setyo N
- 1,953
- 2
- 26
- 28
2
Here is an explanation article plus C# code:
http://www.imagingshop.com/articles/least-squares
It uses Math.NET Numerics for linear algebra to simplify the Levenberg-Marquardt algorithm.

Libor
- 3,285
- 1
- 33
- 41