Skip to main content

Appendix C — Python and mathematics labs

Each chapter has two companion notebooks. The practice notebook includes all end-of-chapter questions, with empty working cells for computations. The solutions notebook contains the complete worked mathematical solutions and runnable Python cells. Work in the first notebook before opening the second.

All examples use synthetic, reproducible data. No private datasets, external API keys, paid computing services, or special hardware are required.

Choose Colab to open a notebook directly in your browser, or Download to save the original .ipynb file for local Jupyter or manual upload. No installation is needed to work in Colab; sign in to Google when prompted to connect a runtime and save a copy.

C.1 Chapter notebooks

Chapter Try independently Worked answers
1. Probability spaces Colab Download Colab Download
2. Conditioning and Bayes’ rule Colab Download Colab Download
3. Discrete random variables Colab Download Colab Download
4. Continuous random variables Colab Download Colab Download
5. Joint distributions Colab Download Colab Download
6. Random vectors Colab Download Colab Download
7. Transformations and sums Colab Download Colab Download
8. Moments and generating functions Colab Download Colab Download
9. Convergence and limit theorems Colab Download Colab Download
10. Sampling and simulation Colab Download Colab Download
11. Estimation and MLE Colab Download Colab Download
12. Confidence intervals Colab Download Colab Download
13. Hypothesis tests Colab Download Colab Download
14. Bayesian inference Colab Download Colab Download
15. Markov chains Colab Download Colab Download
16. Regression and classification Colab Download Colab Download

C.2 How to use a notebook

  • Click Colab next to the notebook you want to work through. In Colab, sign in if prompted, then choose File > Save a copy in Drive to keep your own editable copy and progress.
  • Connect a runtime and click the play button next to a code cell. Practice notebooks provide empty working cells; solution notebooks contain runnable code.
  • For JupyterLab or an offline copy, click Download to save the .ipynb file. Open the file in JupyterLab or use Colab’s notebook upload option. Local installation is described in the Python reference.
  • Write the mathematics in Markdown cells and the computational steps in code cells. Use dollar delimiters for LaTeX in notebook Markdown.
  • In each coding problem, first record your predicted result. Run the experiment, compare results, and interpret disagreements using sampling uncertainty.
  • Compare your work with the solutions only after a meaningful attempt. Reproduce the solution without copying on a second pass.

The notebooks and website share a single source: the notebook generation script extracts the questions and solutions from the chapter files. Corrections to the text flow into both downloadable versions when the book is rebuilt.

C.3 A 28-day study schedule

Days Work
1–2 Chapter 1 and two analytical problems; simulate an event
3–4 Chapter 2 and the base-rate experiment
5–6 Chapters 3–4, one discrete and one continuous distribution exercise
7 Review the formula reference; reproduce a simulation from memory
8–9 Chapters 5–6, derive marginals and work with covariance matrices
10 Chapter 7, pursue a Jacobian derivation and inverse-CDF sampler
11 Chapter 8, use generators to solve an independent-sum problem
12–13 Chapter 9 and LLN/CLT labs, including the heavy-tail example
14 Review Week 2 and retry the most difficult proof
15–16 Chapters 10–11, precision, likelihood and bias–variance
17–18 Chapter 12, interval coverage and bootstrap lab
19–20 Chapter 13, test calibration and power
21 Solve a new inference problem with assumptions stated explicitly
22–23 Chapter 14, conjugacy and posterior predictive simulation
24–25 Chapter 15, stationary and hitting-time exercises
26–27 Chapter 16, regression, likelihood and calibration
28 Complete the final probability-model check; identify gaps to revisit

The schedule assumes about two to three focused hours per day. If you are already comfortable with early material, allocate those days to the proof-heavy sections and more challenging exercises. A second pass through selected chapters is a normal part of mathematical study.