Teaching notebooks for the Brainard Lab. Every notebook can be run in the browser with Google Colab — no local install required.
Any notebook in this repo opens in Colab through a URL of this form:
https://colab.research.google.com/github/BrainardLab/PythonTeachingCode/blob/main/<path-to-notebook>.ipynb
Or browse interactively: open https://colab.research.google.com, choose
GitHub, enter BrainardLab/PythonTeachingCode, and pick a notebook.
Colab gives each session a fresh, temporary machine. Changes are not saved back to GitHub. To keep your edits use File → Save a copy in Drive, or File → Download → .ipynb.
Notebooks in notebooks/key/lecture_3.2/:
| Notebook | Open in Colab |
|---|---|
| lecture_3.2_Group_A.ipynb — in-class predict-then-plot, pooled Group A height game | |
| StockChangeDistribution.ipynb — daily S&P 500 moves (fat tails) | |
| HeightDistribution.ipynb — adult women's height, NHANES (nicely normal) | |
| CityPopulationDistribution.ipynb — US city sizes, raw and log10 (lognormal) |
StockChangeDistribution, HeightDistribution, and CityPopulationDistribution
each compare a real data set against a normal distribution using the same
plots and summary table. The shared code lives in
notebooks/key/lecture_3.2/dist_tools.py;
each notebook only loads its data, wraps it in a dist_tools.Distribution, and
calls dist_tools.analyze(). Edit dist_tools.py once and all three notebooks
change together. Each notebook downloads dist_tools.py from GitHub at run time
when it isn't already present, so Colab works with no extra steps.
tools/build_notebooks.py regenerates the three notebooks' shared scaffolding.
-
Put the
.ipynbfile anywhere undernotebooks/. -
Run
python tools/add_colab_badge.pyto insert an "Open in Colab" badge as the first cell (idempotent — safe to re-run on every notebook; it recurses into subfolders). -
Add a row to a table above.
-
Commit and push:
git add notebooks/ README.md git commit -m "Add your_notebook" git push
The pushed notebook is immediately runnable in Colab via its badge link.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
jupyter lab