Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
probml
GitHub Repository: probml/pyprobml
Path: blob/master/notebooks/book1/02/gauss_plot.ipynb
1193 views
Kernel: Python 3 (ipykernel)

CDF and PDF plots of Standard Normal Distribution

import jax import jax.numpy as jnp import seaborn as sns import matplotlib.pyplot as plt try: from probml_utils import latexify, savefig, is_latexify_enabled except ModuleNotFoundError: %pip install -qq git+https://github.com/probml/probml-utils.git from probml_utils import latexify, savefig, is_latexify_enabled from jax.scipy.stats import norm
latexify(width_scale_factor=2, fig_height=1.5)
# Plot pdf and cdf of standard normal x = jnp.linspace(-3, 3, 500) def make_graph(data, save_name): fig, ax = plt.subplots() ax.plot(data["x"], data["y"]) # plt.title("Gaussian pdf") plt.xlabel("$x$") plt.ylabel(data["ylabel"]) sns.despine() savefig(save_name) make_graph({"x": x, "y": norm.pdf(x), "ylabel": "$p(x)$"}, "gaussian1d.pdf") make_graph( {"x": x, "y": norm.cdf(x), "ylabel": "$Pr(X \leq x)$"}, "gaussianCdf.pdf", )
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.) /home/patel_zeel/miniconda3/lib/python3.9/site-packages/probml_utils/plotting.py:79: UserWarning: set FIG_DIR environment variable to save figures warnings.warn("set FIG_DIR environment variable to save figures") /home/patel_zeel/miniconda3/lib/python3.9/site-packages/probml_utils/plotting.py:79: UserWarning: set FIG_DIR environment variable to save figures warnings.warn("set FIG_DIR environment variable to save figures")
Image in a Jupyter notebookImage in a Jupyter notebook