Created
July 25, 2019 12:44
-
-
Save missflash/c3f69cb3ced7ca2d178bec16fa42a4ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.core.pylabtools import figsize | |
from matplotlib import pyplot as plt | |
import numpy as np | |
figsize(12, 3) | |
def logistic(x, beta, alpha=0): | |
return 1.0 / (1.0 + np.exp(np.dot(beta, x) + alpha)) | |
x = np.linspace(-4, 4, 100) | |
plt.plot(x, logistic(x, 1), label=r"$\beta = 1$", ls="--", lw=1) | |
plt.plot(x, logistic(x, 3), label=r"$\beta = 3$", ls="--", lw=1) | |
plt.plot(x, logistic(x, -5), label=r"$\beta = -5$", ls="--", lw=1) | |
plt.plot(x, logistic(x, 1, 1), label=r"$\beta = 1, \alpha = 1$", color="#348ABD") | |
plt.plot(x, logistic(x, 3, -2), label=r"$\beta = 3, \alpha = -2$", color="#A60628") | |
plt.plot(x, logistic(x, -5, 7), label=r"$\beta = -5, \alpha = 7$", color="#7A68A6") | |
plt.xlabel("$x$") | |
plt.ylabel("Logistic function") | |
plt.title("Logistic functions based on $\\alpha$, $\\beta$", fontsize=14) | |
plt.legend(loc="lower left"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment