fermi-lat / Likelihood

BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

fit with SmoothBrokenPowerLaw issue #54

Open dmalishev opened 4 years ago

dmalishev commented 4 years ago

I've noticed, that a fit with SmoothBrokenPowerLaw model leads to clearly wrong best-fit parameters even for relatively bright sources. The best-fit model does not pass through the spectral points (although the initial parameters seems to describe the data relatively well) and best-fit values for e.g. slope Index1 seems always hit the minimal allowed value -5.

I've checked that the flux calculated according to this model looks fine (the model flux describes the data well for reasonable parameters values). I presume thus that the issue could be due to the wrong derivatives (over SmoothBrokenPowerLaw parameters) calculation.

May you check this issue, please?

nmirabal commented 4 years ago

Some advice from Jean and Marianne. The SBPL convergence is tricky, especially if you have a large number of degrees of freedom. It is very rare that beta can actually be fitted. The first solution to try is to fix beta (to 0.2, for example). Setting Scale is also delicate, it should be close to the pivot energy at which the error on flux density is not too large. Having Index1 hit -5 indicates that the model has inverted curvature and indicates an issue. There are a number of factors here and in general the log parabola often converge more easily than the SBPL.

dmalishev commented 4 years ago

Unfortunately fixing beta did not help. I was trying to mimic a simple powerlaw with the broken one by fixing beta, index2 and BreakValue, but still got convergence to non-correct values, please see "best-fit" attached best_fit.txt

nmirabal commented 4 years ago

Having Index1 approach -5 means that the model has inverted curvature, so there is an issue here. It is typically more common to have the model hit the upper limit of -1 rather than the lower limit. Have you tried a log parabola fit?.

dmalishev commented 4 years ago

Yes, I've tried it previously. Everything works fine with LogParabola and a PowerLaw fit

dmalishev commented 4 years ago

Please find results of PL and LogParabola fit of the same data attached. Both look ok to me. pl_lp_fit.txt

nmirabal commented 4 years ago

It is difficult to add more here as the SmoothBrokenPowerLaw function is so finicky. Two final suggestions a) Try to set Scale as close to the break as possible and leave it fixed, b) start experimenting with changing beta between 0.01 and 10 in small increments and again leaving it fixed. With many so many free parameters, it is very rare that SmoothBrokenPowerLaw can actually be fitted.

Areustle commented 4 years ago

We'll need to ensure the gradients are correct with a numerical gradient checker. I'll take care of this if @eacharles can point me to a robust way to call the functions directly in python.

Otherwise I'll have to write it in C++ and no one wants that.