{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# 7, take 01"
      ],
      "id": "91d70834-5873-4591-b6f8-ca40b8388aff"
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {},
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "import scipy as sp"
      ],
      "id": "91946004-52a9-4900-8cff-499b306000cb"
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {},
      "outputs": [],
      "source": [
        "# 4\n",
        "X = sp.stats.binom(30, 0.04)"
      ],
      "id": "339dc92a-c15f-49a5-be13-279bbe7eddc2"
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {},
      "outputs": [
        {
          "output_type": "display_data",
          "metadata": {},
          "data": {
            "text/plain": [
              "np.float64(0.22192374098152245)"
            ]
          }
        }
      ],
      "source": [
        "# 4b\n",
        "X.cdf(2) - X.cdf(1)"
      ],
      "id": "a52dd079-36f1-40ef-9e80-534e4058b9e9"
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {},
      "outputs": [
        {
          "output_type": "display_data",
          "metadata": {},
          "data": {
            "text/plain": [
              "np.float64(0.2219237409815226)"
            ]
          }
        }
      ],
      "source": [
        "X.pmf(2)"
      ],
      "id": "97905ea8-85b3-469d-9148-63f162580d03"
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {},
      "outputs": [
        {
          "output_type": "display_data",
          "metadata": {},
          "data": {
            "text/plain": [
              "np.float64(0.030592884701019507)"
            ]
          }
        }
      ],
      "source": [
        "# 4d\n",
        "1 - X.cdf(3)"
      ],
      "id": "a7596e71-4978-4f61-9039-bb71c1086c58"
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {},
      "outputs": [
        {
          "output_type": "display_data",
          "metadata": {},
          "data": {
            "text/plain": [
              "np.float64(0.030592884701019618)"
            ]
          }
        }
      ],
      "source": [
        "1 - np.sum(X.pmf(np.arange(4)))"
      ],
      "id": "889d2647-dee4-4b12-a130-20003706f79a"
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "The distribution of the original random variables doesn’t matter so long\n",
        "as they have finite variance.\n",
        "\n",
        "The expectation of the mean of the random variables is the mean of the\n",
        "original distribution.\n",
        "\n",
        "With more data the distribution of the sample mean will look\n",
        "increasingly Normal.\n",
        "\n",
        "# 7, take 02\n",
        "\n",
        "If you consider the distribution of a mean of random variable, this\n",
        "distribution will look increasingly Normal as your data tends to\n",
        "infinity.\n",
        "\n",
        "The mean of this distribution will be the expectation of the original\n",
        "random variables.\n",
        "\n",
        "The variance of this distribution will collapse to 0 as the number of\n",
        "random variables increases to infinity.\n",
        "\n",
        "# 8\n",
        "\n",
        "We’ve been visualizing the CLT by randomly drawing means of random\n",
        "variables from arbitrary distributions. We then make a histogram of the\n",
        "many means.\n",
        "\n",
        "We need many means in order to see variation in the potential means.\n",
        "With only one mean, we’d be trying to make a plot of just one number,\n",
        "which obviously won’t tell us ~~anything~~ much about a distribution."
      ],
      "id": "92ac93e3-2660-4ce7-959e-acba66d55131"
    }
  ],
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3 (ipykernel)",
      "language": "python"
    },
    "language_info": {
      "name": "python",
      "codemirror_mode": {
        "name": "ipython",
        "version": "3"
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.12"
    }
  }
}