On Tue, Feb 3, 2015 at 11:14 PM, Sturla Molden <sturla.mol...@gmail.com> wrote:
> Warren Weckesser <warren.weckes...@gmail.com> wrote: > > > 0 if x < 0 > > heaviside(x) = 0.5 if x == 0 > > 1 if x > 0 > > > > This is not correct. The discrete form of the Heaviside step function has > the value 1 for x == 0. > > heaviside = lambda x : 1 - (x < 0).astype(int) > > > By "discrete form", do you mean discrete time (i.e. a function defined on the integers)? Then I agree, the discrete time unit step function is defined as u(k) = 0 k < 0 1 k >= 0 for integer k. The domain of the proposed Heaviside function is not discrete; it is defined for arbitrary floating point (real) arguments. In this case, the choice heaviside(0) = 0.5 is a common convention. See for example, * http://mathworld.wolfram.com/HeavisideStepFunction.html * http://www.mathworks.com/help/symbolic/heaviside.html * http://en.wikipedia.org/wiki/Heaviside_step_function, in particular http://en.wikipedia.org/wiki/Heaviside_step_function#Zero_argument Other common conventions are the right-continuous version that you prefer (heavisde(0) = 1), or the left-continuous version (heaviside(0) = 0). We can accommodate the alternatives with an additional argument that sets the value at 0: heaviside(x, zero_value=0.5) Warren > > Sturla > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion