Answers for "how to define piecewise function i python"

0

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.])
Posted by: Guest on May-17-2021

Code answers related to "how to define piecewise function i python"

Python Answers by Framework

Browse Popular Code Answers by Language