[SciPy-User] broadened step functions
Christian K.
ckkart at hoc.net
Sat Feb 5 04:42:41 EST 2011
Hi,
can you think of a faster way to evaluate a broadened step function,
i.e. the convolution of a heavyside step function with e.g. a Lorentz
function, than this here?
def lbstep(x,amp,pos,sigma,sigmap=100.0):
dx = x[-1]-x[0]
up = x[-1]+5*dx
lo = x[0]-5*dx
f = amp/N.pi
xp = N.linspace(lo,up,1000.0)[:,N.newaxis]
s2 = N.power(sigma,2)
i = trapz(sigma/(N.power(x-xp,2)+s2)/ \
(1+N.exp(-sigmap*(xp-pos))), xp, axis=0)
return f*i
Speed depends naturally on the length of x and xp and the accuracy also
on the upper and lower integration limits.
Thanks for any idea, Christian
More information about the SciPy-User
mailing list