Wednesday, July 3, 2024
HomeLanguagesPythonPython | Numpy np.heaviside() method

Python | Numpy np.heaviside() method

With the help of np.heaviside() method, we can get the heaviside step function by using np.heaviside() method.

Syntax : np.heaviside(array1, array2 or value)
Return : Return the heaviside series.

Example #1 :
In this example we can see that by using np.heaviside() method, we are able to get the array of series of heaviside step function by using this method.




# import numpy
import numpy as np
  
x = np.array([-1.5, 0.5, 0, 0.5, 1.5])
# using np.heaviside() method
gfg = np.heaviside(x, 0.5)
  
print(gfg)


Output :

[0. 1. 0.5 1. 1.]

Example #2 :




# import numpy
import numpy as np
  
x = np.zeros(5)
y = np.array([-1.5, 0.5, 0, 0.5, -1.5])
  
# using np.heaviside() method
gfg = np.heaviside(x, y)
  
print(gfg)


Output :

[-1.5 0.5 0. 0.5 -1.5]

Shaida Kate Naidoo
am passionate about learning the latest technologies available to developers in either a Front End or Back End capacity. I enjoy creating applications that are well designed and responsive, in addition to being user friendly. I thrive in fast paced environments. With a diverse educational and work experience background, I excel at collaborating with teams both local and international. A versatile developer with interests in Software Development and Software Engineering. I consider myself to be adaptable and a self motivated learner. I am interested in new programming technologies, and continuous self improvement.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments