From c0eaaeb752407e4696302ce0d69ab2b1a49a4dfb Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 11 Feb 2008 23:09:36 -0500 Subject: added lorentzian fitting function --- stats.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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): -- cgit v1.2.3