Course notes
What to know before you start, how Python runs and how to keep your work.
Before you start
Be ready to read Python lists, function calls and a short loop. The lessons introduce the statistics and the parts of NumPy, pandas and SciPy that they use.
Work through the 30 investigations in order if the methods are new to you. The first reading, run and question take an estimated 5–9 minutes each. Allow extra time for trying changes and collecting your own data.
Open Published example output to read examples without running Python. The editor, answer checks and storage need JavaScript.
Using Python in your browser
Opening a lesson loads the code into the editor. Python and its statistics packages can load while you read. On a slow connection, this can take a while. Each run starts with fresh user variables.
Use Tab to leave the editor. Ctrl+Enter or ⌘+Enter runs the code from the editor. Stop cancels the current run. The next run starts a fresh Python session. If a run fails, check the error message. The last successful result and its export remain available.
In Editor tools, Restore example opens the original code. Recover draft reopens the most recently replaced draft. On the report page, Use invented starter data changes the next input without replacing your code.
Where the results come from
Published example output comes from the code run during the site build. Your result comes from the code and input used in your browser when you ran it. Compare timing measurements only after checking that the machines, runtimes and timed work suit your question.
Invented values illustrate the arithmetic. A seeded simulation repeats a specified model and sequence. Actual timings describe work recorded during execution. If you choose a CSV for the report, justify where its pairs came from and why they are independent.
Keep your work
This browser saves code drafts, predictions, notes, report fields, answer attempts and reading marks when storage is available. Clearing site data removes those copies. In the course overview, use Save or restore your work to export them. Import replaces matching records, so export the current copy first if you want to keep it.
On a lesson, open Result tools and select Export run to keep the last successful code, output, plots, runtime versions and any input CSV. The selected CSV and the result are held on the open page until you export the run. Keep your original CSV separately.
Python versions and running a downloaded example
The browser uses Pyodide 0.27.7 and the packages in the runtime manifest. This site serves the packages and verifies their hashes during the build. The browser runs your code locally. Python code can make network requests that your browser allows.
Use Download Python in Editor tools to get the script. In a local Python environment, install the packages and run the downloaded file.
python -m pip install numpy==2.0.2 scipy==1.14.1 pandas==2.2.3 matplotlib==3.9.4 python downloaded-investigation.py
For the report example, place your selected CSV beside the script as data.csv. To display or save a plot locally, add plt.show() or plt.savefig("figure.svg") to the end of a plot example. KaTeX licence.
Glossary
- Treatment
- A condition deliberately assigned in an experiment.
- Response
- The outcome measured under a stated procedure and boundary.
- Confounder
- A variable related to treatment and outcome that can tangle their observed relationship.
- Experimental unit
- The smallest unit independently assigned a treatment; repeated readings within it are subsamples.
- Block / pair
- Observations grouped by a shared condition so treatments can be compared within that group.
- Randomisation
- A chance procedure for assigning treatment or order; it does not guarantee exact balance in one experiment.
- Interaction
- The effect of one factor depends on another factor’s level.
- Population / sample
- The collection you want to describe / the subset you observe.
- Standard deviation
- Spread of individual observations around their mean, in the observations’ units.
- Standard error
- Estimated variability of an estimator across repeated samples under a stated model.
- Confidence interval
- An interval from a procedure with a stated repeated-sampling coverage target, under its assumptions.
- Bootstrap
- Resample observed units with replacement and recalculate a statistic to approximate sampling variation.
- Null model
- A reference claim plus assumptions that describe how observations would vary if that claim held.
- p-value
- A tail probability for the observed statistic under a specified null model and test rule; not the probability the null is true.
- Power
- Probability a specified test rejects its null under a particular alternative model.
- Effect size
- The magnitude of a difference or relationship, expressed in an interpretable unit or scale.
- Residual
- An observed value minus its model prediction.
- Reproducibility / replication
- Here: rerunning a calculation on saved inputs / collecting new evidence to examine a finding. Usage varies across fields.
Sources and acknowledgements
The original examples draw on the author’s Assembly Lab, Event Streaming Lab and Benchmarking Lab. Code is Apache-2.0 and course prose is CC BY-NC 4.0. Third-party packages retain their own licences.
- NIST · Choosing an experimental design ↗
- NIST · Exploratory data analysis ↗
- NumPy · Random sampling ↗
- NIST · Confidence limits for the mean ↗
- pandas · Missing data ↗
- SciPy 1.14 · bootstrap ↗
- ASA · Statement on p-values ↗
- SciPy 1.14 · permutation_test ↗
- SciPy 1.14 · linregress ↗
- Center for Open Science · Preregistration ↗
- Python 3.12 · Performance counter ↗
The repository records the source review and functional checks. Learning effectiveness remains unmeasured.