# commons-user mailing list archives

##### Site index · List index
Message view
Top
From Gilles <gil...@harfang.homelinux.org>
Subject Re: [math3.fitting.leastsquares]
Date Fri, 01 Aug 2014 23:03:43 GMT
```Hi.

On Fri, 01 Aug 2014 18:29:33 +0200, Benjamin Eltzner wrote:
> Dear mailing list,
>
> I would like to do a Levenberg-Marquardt least mean square fit (i. e.
> min( |f(x)|^2 ) for f: R^d -> R^n, d in [2,8], n in [~50, ~10000])
> using
>
> org.apache.commons.math3.fitting.leastsquares.LevenbergMarquardtOptimizer
> and
> I am somewhat confused by the relevant API.
>
> tl/dr: Is there a way to do this in a simple way, providing only a
> function f, its derivative function df and an initial guess for x?
>
> Long form: it seems that I have to create a LeastSquaresProblem which
> requires a lot of input
>
> * MultivariateVectorFunction model: done
> * MultivariateMatrixFunction jacobian: done
> * double[] observed: [0,...,0] in my case, since i want least mean
> squares, right?

Not necessarily. The algorithm will look for the set of parameters
x = ( x_1, x_2, ..., x_d )
for which f(x) = c_1, c_2, ..., c_n is closest to the "observed"
values o_1, o_2, ..., o_n.

> * double[] start: done
> * RealMatrix weight: should this be a "new DiagonalMatrix([1,...,1])"
> of
> the dimension of "observed"?

A diagonal matrix of unit weights is the default.

> * ConvergenceChecker<LeastSquaresProblem.Evaluation> checker: no clue

It's a user-defined check for convergence.
But you can set it to "null": the standard Levenberg-Marquardt
procedure
for checking convergence will then be used.

> * int maxEvaluations: no clue
> * int maxIterations: no clue

These are intended to avoid running "forever": "maxEvaluations" sets a
limit to the number of evaluations of f(x), "maxIterations" limits the
number of iteration of the optimizer's main loop.
If you are confident that the problem is well behaved, you can set them
to "Integer.MAX_VALUE".

>
> Is there a way to get "reasonable defaults" for the three or four
> last
> arguments? Or put differently, what would be "typical" inputs for the
> last four arguments?
>
> I would be very glad, if you could help me with this problem. I have
> been trying to figure out, what would be sensible inputs be reading
> the
> source code, but I guess it would take ages until I really understood
> what is going on there. The results of a trial-and-error approach
> have
> also been rather disappointing so far.

The user guide should be updated; sorry for that.

Best regards,
Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org

```
Mime
View raw message