Skip to content

Instantly share code, notes, and snippets.

@missflash
Created July 25, 2019 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save missflash/c3f69cb3ced7ca2d178bec16fa42a4ce to your computer and use it in GitHub Desktop.
Save missflash/c3f69cb3ced7ca2d178bec16fa42a4ce to your computer and use it in GitHub Desktop.
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