<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 3, 2015 at 11:14 PM, Sturla Molden <span dir="ltr"><<a href="mailto:sturla.molden@gmail.com" target="_blank">sturla.molden@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">Warren Weckesser <<a href="mailto:warren.weckesser@gmail.com">warren.weckesser@gmail.com</a>> wrote:<br>
<br>
>                     0    if x < 0<br>
>     heaviside(x) =  0.5  if x == 0<br>
>                     1    if x > 0<br>
><br>
<br>
</span>This is not correct. The discrete form of the Heaviside step function has<br>
the value 1 for x == 0.<br>
<br>
heaviside = lambda x : 1 - (x < 0).astype(int)<br>
<span class=""><font color="#888888"><br>
<br></font></span></blockquote><div><br><br><br>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<br><br><span style="font-family:monospace,monospace">    u(k) = 0  k < 0<br>           1  k >= 0</span><br><br>for integer k.<br><br>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,<br><br>* <a href="http://mathworld.wolfram.com/HeavisideStepFunction.html">http://mathworld.wolfram.com/HeavisideStepFunction.html</a><br>* <a href="http://www.mathworks.com/help/symbolic/heaviside.html">http://www.mathworks.com/help/symbolic/heaviside.html</a><br>* <a href="http://en.wikipedia.org/wiki/Heaviside_step_function">http://en.wikipedia.org/wiki/Heaviside_step_function</a>, in particular <a href="http://en.wikipedia.org/wiki/Heaviside_step_function#Zero_argument">http://en.wikipedia.org/wiki/Heaviside_step_function#Zero_argument</a><br><br>Other common conventions are the right-continuous version that you prefer (heavisde(0) = 1), or the left-continuous version (heaviside(0) = 0).<br><br>We can accommodate the alternatives with an additional argument that sets the value at 0:<br><br>    heaviside(x, zero_value=0.5)<br><br><br></div><div>Warren<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=""><font color="#888888">
<br>
Sturla<br>
</font></span><div class=""><div class="h5"><br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br></div></div>