[AstroPy] Info LevMarLSQFitter

Diana Scognamiglio dianasco at astro.uni-bonn.de
Thu May 14 10:00:32 EDT 2020


Dear Zé, Peter, Peter and Paul,
thanks for your reply.
I didn't find yet the solution to my problem.
The problems could be due to the fact that the fit just converges in a local 
minimum and not in the global one or to the fact the the fit is not well 
constrained...in any case it sometimes completely fails giving for example 
flux=0!
I should use some particular constraints for the fitting I guess...and 
probably it will be the best solution.

About the Peter (Dwing)’s questions: I chose these ranges for the initial 
parameters: n_Sersic=[1.0,2.0,3.0,4.0,5.0,6.0] and  R_eff=[1.0,5.0, 10.0, 
30.0, 50.0,100.0], and ini_flux=[100, 1000].
If I repeat the run (using the same initial parameters), yes I get the same 
results.

I also used the SimplexLSQFitter, but the things doesn’t change.

Thanks again.
Cheers,
Diana

On Tue, 12 May 2020 14:36:11 +0200
         Peter Erwin <peter.erwin at gmail.com> wrote:
> Hi Zé,
> 
> As an aside, the fact that the Sersic2D model is nonlinear in its parameters is formally
> irrelevant, since Levernberg-Marquardt is by design a *non-linear least-squares* algorithm.
> (Levenberg’s original 1944 paper describing the algorithm was titled "A Method for the Solution of Certain Non-Linear Problems in Least Squares”.)
> 
> In practice, I find that Levenberg-Marquardt *usually* finds the global minimum
> in galaxy image-fitting problems (e.g., I get the same solution when running Imfit
> with Levenberg-Marquardt or with the Differential Evolution algorithm, which
> doesn’t use initial values), though there *are* cases where L-M does get trapped in
> local minima. (The fact that Diana says she “always” gets a different result for different starting parameters maybe suggests something else is the problem.)
> 
> 
> Diana — have you tried using an alternate fitting algorithm, such as the SimplexLSQFitter
> class? (Simplex fitters tend to be less likely to be trapped by local minima than
> Levenberg-Marquardt, though they’re usually significantly slower.)
> 
> 
> cheers,
> 
> Peter [Erwin]
> 
>> On May 12, 2020, at 11:17 AM, Zé Vinícius <jvmirca at gmail.com> wrote:
>> 
>> Hi Diana,
>> 
>> From my understanding, LevMarLSQFitter uses the least-squares function as the objective to be minimized using the Levenberg-Marquardt algorithm.
>> 
>> Because Sersic2D is a non-linear model on the parameters to be fitted, the problem is most likely non-convex, which means that Levenberg-Marquardt only guarantees to find a local solution, which will depend on the initial value for those parameters.
>> 
>> Best,
>>>> 
>> On Tue, May 12, 2020 at 4:53 PM Diana Scognamiglio <dianasco at astro.uni-bonn.de> wrote:
>> Dear Astropy Staff,
>> 
>> I am Diana Scognamiglio and I have some problems to deep understand how LevMarLSQFitter works.
>> 
>> I am trying to fit a mock Sersic galaxy using the LevMarLSQFitter classe, coding these lines:
>> 
>>  
>> ini_mod =
>> EllipSersic2D(flux=ini_flux, r_eff=ini_r_eff, n=ini_n, x_0=stampsize/2.0, y_0=stampsize/2.0, g1=0.0, g2=0.0)
>> 
>> fitter = fitting.LevMarLSQFitter()
>> 
>> fit_mod = fitter(ini_mod, x_array, y_array, stamp, weights=weights, maxiter = 1000, acc=1.0e-7, epsilon=1.0e-6,
>> estimate_jacobian=False)   I have figured out that if I change the initial parameters in ini_mod (i.e., ini_flux, ini_r_eff, etc), I counterintuitively obtain always a different result although the galaxy I am fitting is the same. How does the fit depend on those initial parameters?
>> 
>> Please, can you help me with this issue?
>> 
>> Thank you in advance.
>> 
>> I wait for hearing from you.
>> 
>> Best regards,
>> 
>> Diana Scognamiglio
>> 
>>  
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at python.org
>> https://mail.python.org/mailman/listinfo/astropy
>> 
>> 
>> -- 
>> Zé Vinícius
>> https://mirca.github.io
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at python.org
>> https://mail.python.org/mailman/listinfo/astropy
> 
> =============================================================
> Peter Erwin                   Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de              Physics, Giessenbachstrasse
> tel. +49 (0)176 2481 7713     85748 Garching, Germany
> fax  +49 (0)89 30000 3495    https://www.mpe.mpg.de/~erwin
> 
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy











More information about the AstroPy mailing list