[Numpy-discussion] Any interest in a 'heaviside' ufunc?

Sturla Molden sturla.molden at gmail.com
Tue Feb 3 23:14:09 EST 2015


Warren Weckesser <warren.weckesser at 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)



Sturla




More information about the NumPy-Discussion mailing list