[AstroPy] non-linear least square fitting in python

gonghang.naoc ghang.naoc at gmail.com
Thu May 14 09:04:32 EDT 2015


*Hi Tom,For y=a*e^(-b*x) , we can get an analytic solution. So it is not
necessary to guess. For y=a*e^(-b*x)+c, we can not get an analytic
solution, right?*

*Hang*

On Thu, May 14, 2015 at 6:47 PM, Aldcroft, Thomas <
aldcroft at head.cfa.harvard.edu> wrote:

>
>
> On Thu, May 14, 2015 at 5:52 AM, gonghang.naoc <ghang.naoc at gmail.com>
> wrote:
>
>> Hi all,
>> We can use scipy.optimize.leastsq to do least square fitting in python.
>> However we need to make an initial guess. (
>> http://python4mpia.github.io/fitting_data/least-squares-fitting.html).
>> So I am not sure we can get a global optimum.
>>
>
> Ensuring that you have a global optimum for a non-linear is generally a
> difficult problem.  In your case though you have a reasonably simple fit
> function so that if you provide a decent initial guess then most optimizers
> should converge to something near the global optimum.
>
> You can make an initial guess in your case by taking 3 data points, at the
> beginning, middle, and end of your data.  With those three data points you
> can analytically solve for a, b, and c.  Then use those as the starting
> point.  If your data are very noisy you might average a few.
>
> Cheers,
> Tom
>
>
>>
>> There is other simple way we can fit a *y=a*e^-(b*x)+c* curve? My data
>> are  Xn, Yn and ERRORn. A constant c makes the fitting difficult since we
>> can not make a log on both sides and use linear fitting any more.
>>
>> Thank you.
>> best
>> Hang
>>
>>
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy
>>
>>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20150514/e92fa414/attachment.html>


More information about the AstroPy mailing list