Jupyter notebooks with the Python equivalent to the R code sections in Blitzstein and Hwang's Introduction To Probability, Second Edition
The Anaconda Python distribution comes highly recommended, as it includes Python, the conda package manager, the Spyder integrated development environment, and a whole universe of Python packages for mathematics and engineering, including NumPy, SciPy, Matplotlib and Jupyter.
-
Jupyter (v1.0.0)
-
NumPy (v1.13.0)
-
SciPy (v0.19.1)
-
Matplotlib (v2.1.0)
-
ipywidgets (v7.4.2) ... interactive game for the Monty Hall problem in Chapter 2
-
D3.js (v5.7.0) on the Google Hosted Libraries content delivery network referenced from the interactive visualization for the Central Limit Theorem in Chapter 10
After installing Python and Jupyter, navigate to this project's home directory where these notebooks are saved, open up a command window or shell interface, and type the following command:
jupyter notebook
Your default browser will open up to show the Notebook Dashboard at http://localhost:8888
.
MathJax is the JavaScript library Jupyter uses to render . To ensure that you have the absolute, latest version of MathJax rendering the math in your locally-executed notebooks, set the NotebookApp.enable_mathjax
configuration parameter in jupyter_notebook_config.py
to point to the newest available MathJax.js version on cdnjs. (c.f. Config file and command line options, Jupyter docs).
These notebooks have been confirmed to run on:
- Chrome 71.0.3578.98 (official build), 64-bit and Firefox 64.0, 64-bit on Windows 10
- Chrome 69.0.3497.100 (official build, 64-bit and Firefox 52.8.0, 64-bit on Windows 7
- Chrome 71.0.3578.98 (official build), 64-bit; Firefox 64.0 (64-bit); and Safari 12.0.2 (13606.3.4.1.4) on macOS (High Sierra, v10.13.6)
Internet Explorer is not recommended!
- Ch1 - Probability and Counting: Vectors; Factorials and binomial coefficients; Sampling and simulation; Matching problem simulation; Birthday problem calculation and simulation
- Ch2 - Conditional Probability: Simulating the frequentist interpretation; Monty Hall simulation
- Ch3 - Random Variables and their Distributions: Distributions in SciPy; Binomial distribution; Hypergeometric distribution; Discrete distributions with finite support
- Ch4 - Expectation: Geometric, Negative Binomial, and Poisson; Matching simulation; Distinct birthdays simulation
- Ch5 - Continuous Random Variables: Uniform, Normal and Exponential distributions; Plots in Matplotlib; Universality with Logistic; Poisson process simulation
- Ch6 - Moments: Functions; Moments; Medians and modes; Dice simulation
- Ch7 - Joint Distributions: Multinomial; Multivariate Normal; Cauchy
- Ch8 - Transformations: Beta and Gamma distributions; Convolution of Uniforms; Bayes' billiards; Simulating order statistics
- Ch9 - Conditional Expectation: Mystery prize simulation; Time until HH vs. HT; Linear regression
- Ch10 - Inequalities and Limit Theorems: Jensen's inequality; Visualization of the law of large numbers; Monte Carlo estimate of π; Visualizations of the central limit theorem; Chi-Square and Student-t distributions
- Ch11 - Markov Chains: Matrix calculations; Gambler's ruin; Simulating from a finite-state Markov chain
- Ch12 - Markov Chain Monte Carlo: Metropolis-Hastings; Gibbs
- Ch13 - Poisson Processes: 1D Poisson process; Thinning; 2D Poisson process
- Appendix B - Python / NumPy / SciPy
Joseph K. Blitzstein and Jessica Hwang, Harvard University and Stanford University, © 2019 by Taylor and Francis Group, LLC