{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Descriptive Statistics and Exploratory Data Analysis\n",
        "\n**Opening question:** How can a dataset be summarized without letting one number erase its shape?\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import pandas as pd\n",
        "from scipy import stats\n",
        "\n",
        "x = pd.Series([10, 11, 12, 13, 55])\n",
        "print({\n",
        "    \"mean\": x.mean(),\n",
        "    \"median\": x.median(),\n",
        "    \"std\": x.std(),\n",
        "    \"iqr\": stats.iqr(x),\n",
        "})\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Interpretation check:** Interpretation. The extreme value pulls the mean and standard deviation upward, while the median and IQR remain close to the central cluster.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "from scipy import stats\n",
        "\n",
        "rng = np.random.default_rng(13)\n",
        "returns = rng.standard_t(df=5, size=5_000)\n",
        "print(round(stats.skew(returns), 3))\n",
        "print(round(stats.kurtosis(returns, fisher=True), 3))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Interpretation check:** Interpretation. The excess kurtosis is well above zero, consistent with heavier tails than a normal distribution.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Verified source output\n",
        "\n",
        "```text\n{'mean': np.float64(20.2), 'median': np.float64(12.0), 'std': np.float64(19.485892332659542), 'iqr': np.float64(2.0)}\n```\n\n```text\n0.302 10.268\n```\n\n```text\n0.302\n10.268\n```\n\n```text\nimport pandas as pd\nfrom scipy import stats\nx = pd.Series([10, 11, 12, 13, 55])\nprint({\n\"mean\": x.mean(),\n\"median\": x.median(),\n```\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3"
    },
    "ceteris_lab": {
      "course_slug": "fundamentals-python-econometrics",
      "source_derived": true,
      "course_title": "Fundamentals of Python for Financial Econometrics",
      "chapter": 13,
      "source_origin": "source-derived"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
