summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@charm.mit.edu>2008-02-11 23:09:36 -0500
committerBryan Newbold <bnewbold@charm.mit.edu>2008-02-11 23:09:36 -0500
commitc0eaaeb752407e4696302ce0d69ab2b1a49a4dfb (patch)
tree89afc7c12f4d05dd1624fbcad255c2fd517540a0
parent81a0c260d321da151e244548188d13a963bf111f (diff)
downloadscipy-jlab-c0eaaeb752407e4696302ce0d69ab2b1a49a4dfb.zip
scipy-jlab-c0eaaeb752407e4696302ce0d69ab2b1a49a4dfb.tar.gz
added lorentzian fitting function
-rw-r--r--stats.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/stats.py b/stats.py
index 3315968..9acf3f4 100644
--- a/stats.py
+++ b/stats.py
@@ -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):