# Chapter 13: Descriptive Statistics and Exploratory Data Analysis
# Fundamentals of Python for Financial Econometrics - Descriptive Statistics and Exploratory Data Analysis
# Dataset: Ceteris Lab teaching sample

# Descriptive Statistics and Exploratory Data Analysis
#
# **Opening question:** How can a dataset be summarized without letting one number erase its shape?

# %% Cell 2
import pandas as pd
from scipy import stats

x = pd.Series([10, 11, 12, 13, 55])
print({
    "mean": x.mean(),
    "median": x.median(),
    "std": x.std(),
    "iqr": stats.iqr(x),
})

# **Interpretation check:** Interpretation. The extreme value pulls the mean and standard deviation upward, while the median and IQR remain close to the central cluster.

# %% Cell 4
import numpy as np
from scipy import stats

rng = np.random.default_rng(13)
returns = rng.standard_t(df=5, size=5_000)
print(round(stats.skew(returns), 3))
print(round(stats.kurtosis(returns, fisher=True), 3))

# **Interpretation check:** Interpretation. The excess kurtosis is well above zero, consistent with heavier tails than a normal distribution.

# Verified source output
#
# ```text
# {'mean': np.float64(20.2), 'median': np.float64(12.0), 'std': np.float64(19.485892332659542), 'iqr': np.float64(2.0)}
# ```
#
# ```text
# 0.302 10.268
# ```
#
# ```text
# 0.302
# 10.268
# ```
#
# ```text
# import pandas as pd
# from scipy import stats
# x = pd.Series([10, 11, 12, 13, 55])
# print({
# "mean": x.mean(),
# "median": x.median(),
# ```
