Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to define piecewise function i python

>>> x = np.linspace(-2.5, 2.5, 6)
>>> np.piecewise(x, [x < 0, x >= 0], [-1, 1])
array([-1., -1., -1.,  1.,  1.,  1.])
Source by numpy.org #
 
PREVIOUS NEXT
Tagged: #define #piecewise #function #python
ADD COMMENT
Topic
Name
3+2 =