We have sign which is basically the same thing:
In [1]: sign(x)
Out[1]: sign(x)
In [2]: sign(1)
Out[2]: 1
In [3]: sign(-5)
Out[3]: -1
Ondrej
And so you have the heaviside function:
In [1]: H=Lambda(x, (sign(x)+1)/2)
In [2]: H(-1)
Out[2]: 0
In [3]: H(0)
Out[3]: 1
In [4]: H(1)
Out[4]: 1
By, Friedrich
I think there is a bug here. sign(0) should be 0 (and as a consequence
H(0) should be 1/2).
Fredrik
I think you are rigth. Here is a patch for this.
By, Friedrich
It's in, thanks. Now it works as expected:
In [6]: H=Lambda(x, (sign(x)+1)/2)
In [7]: H(-1)
Out[7]: 0
In [8]: H(1)
Out[8]: 1
In [9]: H(0)
Out[9]: 1/2
Ondrej