Learning Statistics with Python
  • Cover
  • Ch 0
  • Ch 1
  • Ch 2
  • Ch 3
  • Ch 4
  • Ch 5
  • Ch 6
  • Ch 7
  • 📖 Book

Learning Statistics with Python

Companion slide decks

Learning Statistics with Python

Companion slide decks for ISOM 5650 · interactive, runs Python in your browser

Prof. Xuhu Wan · ISOM, HKUST Business School · 2026 Edition

Pick a chapter for the full deck, or jump straight to a section mini-deck. Every deck runs Python through Pyodide: predict the output, run the cell, edit it, break it. The companion book is at statpython-book.pages.dev.

Chapter 0

Basics of Python

Python as a calculator, numbers, strings, lists, tuples, sets, dictionaries, control flow, comprehensions, functions, error handling.

  • §0.1 Python as a Calculator: Numbers, Booleans, Strings
  • §0.2 Containers: Lists, Tuples, Sets, Dictionaries
  • §0.3 Control Flow and List Comprehensions
  • §0.4 Functions, Lambdas, f-strings, and Error Handling
4 sections · full deck: Chapter 0 →
Chapter 1

Data Structures and Methods of Series

pandas Series end to end: operators, aggregation, apply/where, missing data, sorting, clipping, ranking, binning, indexing, dates, rolling windows, resampling, plotting.

  • §1.1 Series Basics, Operators, Aggregation and Conversion
  • §1.2 Manipulation: apply, where, Missing Data, Sorting, Clipping, Ranking, Binning
  • §1.3 Indexing: rename, reset_index, loc and iloc, Sampling, Reindexing
  • §1.4 Dates and Time: Shifting, Rolling, Cumulative, Resampling, Plotting
4 sections · full deck: Chapter 1 →
Chapter 2

DataFrames

DataFrame methods end to end: axes and alignment, agg and apply, missing and duplicated values, filtering, groupby, pivot, melt, stack, merging and concatenation, and the modern method-chaining style.

  • §2.1 DataFrame Axes, Sorting, Index Alignment, agg and apply
  • §2.2 Missing and Duplicated Values, Filtering, Subset Selection
  • §2.3 Groupby, Pivoting, Melting, Stacking, Concatenation
  • §2.4 Method Chaining and Pandas Idioms
4 sections · full deck: Chapter 2 →
Chapter 3

Reshaping Statistics

From averages to distributions: empirical and theoretical distributions, bootstrap confidence intervals and hypothesis tests, experimental design with A/B tests and bandits, linear and nonlinear association, and extreme value theory for the tails.

  • §3.1 Population vs Sample and Distributions in Practice
  • §3.2 Bootstrap Confidence Intervals and Hypothesis Testing
  • §3.3 Experimental Design: A/B Tests and Bandits
  • §3.4 Association: Linear, Monotonic, and Nonlinear
  • §3.5 Extreme Value Theory: GEV, Block Maxima, POT, Extreme VaR
5 sections · full deck: Chapter 3 →
Chapter 4

Statistical Predictive Models

Credit-risk case (default, EAD, LGD): feature engineering, multiple regression, model selection, inference, trees and boosting, logistic classification, and why prediction is not causation, plus attention-based cross-sectional features.

  • §4.1 Credit Risk Data: Default, EAD, LGD, Feature Engineering, Multiple Regression
  • §4.2 Model Selection: Adjusted R², Interactions, Best Subset, Inference, Multicollinearity
  • §4.3 Nonlinear Models: Trees, Random Forests, Gradient Boosting, Logistic Classification
  • §4.4 Causal Analysis: Prediction vs Causation, Confounders, Difference-in-Differences, Instrumental Variables
  • §4.5 Cross-Sectional Attention Features: Transformers for the Stock Cross-Section
5 sections · full deck: Chapter 4 →
Chapter 5

Rethinking Statistics with Bayesian Methods

Priors, likelihoods and posteriors for risk and reward, credible intervals, Bayesian regression with predictive checks, robust regression with fat tails, dynamic updating.

  • §5.1 A Bayesian Model of Risk and Reward: Priors, Likelihood, Posterior of the Sharpe Ratio
  • §5.2 Bayesian Regression and Prior/Posterior Predictive Checks
  • §5.3 Robust Regression with Fat Tails
  • §5.4 Dynamic Bayesian Models: Rolling Updates and Adaptive Risk
4 sections · full deck: Chapter 5 →
Chapter 6

Time Series Models for Trading and Risk

Stationarity, ACF/PACF and ARIMA as the foundations — then where time-series models still earn their keep in quant trading: volatility (ARCH/GARCH/GJR, VaR, vol targeting), structural arbitrage (cointegration and pairs, Kalman hedge ratios, regime switching), and the walk-forward discipline that underpins every ML pipeline. Mean forecasting itself has largely been ceded to ML.

  • §6.1 Foundations: Stationarity, Unit Roots, ACF/PACF, ARIMA as a Baseline
  • §6.2 Why Mean Forecasting Lost to ML: Forecast Accuracy, Walk-Forward Discipline, Time Series as the Base of the ML Pipeline
  • §6.3 Structural Arbitrage I: Cointegration and Pairs Trading
  • §6.4 Structural Arbitrage II: Kalman Filters and Regime Switching
  • §6.5 Volatility I: ARCH, GARCH(1,1), Forecasts and VaR
  • §6.6 Volatility II: Leverage (GJR), ARMA+GARCH, and Volatility Targeting
6 sections · full deck: Chapter 6 →
Chapter 7

Modern Statistical Learning in Practice

Six methods that have moved from research papers into everyday practice, each built on what earlier chapters taught: learning to rank, quantile and conformal prediction, double machine learning, covariance shrinkage and cluster-based allocation, event-based labels and meta-labeling, and the statistics that decide whether a discovered pattern is real. The demonstrations use market data; the methods are used far beyond it — search and recommendation, demand forecasting, policy and marketing evaluation, any high-dimensional covariance, two-stage decision systems, and large-scale experimentation.

  • §7.1 Learning to Rank
  • §7.2 Quantile and Conformal Prediction: Intervals, Not Points
  • §7.3 Double Machine Learning: Effects with Many Controls
  • §7.4 Covariance Shrinkage and Cluster-Based Allocation (Hierarchical Risk Parity)
  • §7.5 Event-Based Labels and Meta-Labeling: Triple Barriers and Two-Stage Decisions
  • §7.6 Selection Statistics: Deflated Performance, Overfitting Probability, and 42 Rules on Trial
6 sections · full deck: Chapter 7 →
 

© 2026 Prof. Xuhu Wan · ISOM, HKUST Business School