{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Normal distribution: histogram and PDF\n\nExplore the normal distribution: a histogram built from samples and the\nPDF (probability density function).\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport scipy as sp\nimport matplotlib.pyplot as plt\n\ndist = sp.stats.norm(loc=0, scale=1)  # standard normal distribution\nsample = dist.rvs(size=100000)  # \"random variate sample\"\nplt.hist(\n    sample,\n    bins=51,  # group the observations into 50 bins\n    density=True,  # normalize the frequencies\n    label=\"normalized histogram\",\n)\n\nx = np.linspace(-5, 5)  # possible values of the random variable\nplt.plot(x, dist.pdf(x), label=\"PDF\")\nplt.legend()\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.11"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}