TIPE-OperationValkyrie-Absobel/fig/replaced_by_d3/sigmoid.py

24 lines
426 B
Python

"""
sigmoid
~~~~~~~
Plots a graph of the sigmoid function."""
import numpy
import matplotlib.pyplot as plt
z = numpy.arange(-5, 5, .1)
sigma_fn = numpy.vectorize(lambda z: 1/(1+numpy.exp(-z)))
sigma = sigma_fn(z)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(z, sigma)
ax.set_ylim([-0.5, 1.5])
ax.set_xlim([-5,5])
ax.grid(True)
ax.set_xlabel('z')
ax.set_title('sigmoid function')
plt.show()