[Numpy-discussion] lsq problem
Tommy Grav
tgrav at mac.com
Wed Feb 14 21:48:44 EST 2007
I need to fit a gaussian profile to a set of points and would like to
use scipy (or numpy) to
do the least square fitting if possible. I am however unsure if the
proper routines are
available, so I thought I would ask to get some hints to get going in
the right direction.
The input are two 1-dimensional arrays x and flux, together with a
function
def Gaussian(a,b,c,x1):
return a*exp(-(pow(x1,2)/pow(c,2))) - c
I would like to find the values of (a,b,c), such that the difference
between the gaussian
and fluxes are minimalized. Would scipy.linalg.lstsq be the right
function to use, or is this
problem not linear? (I know I could find out this particular problem
with a little research, but
I am under a little time pressure and I can not for the life of me
remember my old math
classes). If the problem is not linear, is there another function
that can be used or do I have
to code up my own lstsq function to solve the problem?
Thanks in advance for any hints to the answers.
Cheers
Tommy
More information about the NumPy-Discussion
mailing list