Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
probml
GitHub Repository: probml/pyprobml
Path: blob/master/notebooks/book2/15/probit_plot.ipynb
1192 views
Kernel: Python 3 (ipykernel)
# Plots Sigmoid vs. Probit. import numpy as np import matplotlib.pyplot as plt try: from probml_utils import savefig, latexify except ModuleNotFoundError: %pip install -qq git+https://github.com/probml/probml-utils.git from probml_utils import savefig, latexify import seaborn as sns from scipy.special import expit from scipy.stats import norm
# import os # os.environ["LATEXIFY"] = "1" # os.environ["FIG_DIR"] = "."
latexify(width_scale_factor=2, fig_height=1.5)
x = np.arange(-6, 6, 0.1) l = np.sqrt(np.pi / 8) plt.plot(x, expit(x), "r-", label="sigmoid") plt.plot(x, norm.cdf(l * x), "b--", label="probit") plt.xlabel("$x$") plt.ylabel("$f(x)$") plt.axis([-6, 6, 0, 1]) plt.legend() sns.despine() savefig("probitSigmoidPlot.pdf") plt.show()
/home/prey241/.local/lib/python3.8/site-packages/probml_utils/plotting.py:69: UserWarning: renaming ./probitSigmoidPlot.pdf to ./probitSigmoidPlot_latexified.pdf because LATEXIFY is True warnings.warn(
saving image to ./probitSigmoidPlot_latexified.pdf Figure size: [3. 1.5]