diff options
author | Bryan Newbold <bnewbold@charm.mit.edu> | 2008-02-11 23:09:36 -0500 |
---|---|---|
committer | Bryan Newbold <bnewbold@charm.mit.edu> | 2008-02-11 23:09:36 -0500 |
commit | c0eaaeb752407e4696302ce0d69ab2b1a49a4dfb (patch) | |
tree | 89afc7c12f4d05dd1624fbcad255c2fd517540a0 | |
parent | 81a0c260d321da151e244548188d13a963bf111f (diff) | |
download | scipy-jlab-c0eaaeb752407e4696302ce0d69ab2b1a49a4dfb.tar.gz scipy-jlab-c0eaaeb752407e4696302ce0d69ab2b1a49a4dfb.zip |
added lorentzian fitting function
-rw-r--r-- | stats.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -149,7 +149,10 @@ def fittodata_exp(tx,ty,p0,err=None,floor=1.,ret_all=False): def fittodata_lorentz(tx,ty,p0,err=None,floor=1.,ret_all=False): """runs fittodata for a lorentzian (first param is gamma, second param is mean)""" - lorentz_func = lambda a,b: a[0]/(2.*pi*((a[1]-b)**2+(a[0]/2.)**2. )) + bigsum = scipy.integrate.simps(ty,x=tx) + if type(p0) == type(0.1): + p0 = [p0,] + lorentz_func = lambda a,b: bigsum * a[0]/(2.*pi*((a[1]-b)**2+(a[0]/2.)**2. )) return fittodata(tx,ty,p0,lorentz_func,err=err,floor=floor,ret_all=ret_all); def plotfit(indict,newfig=True): |