THE FIELD NOTES

Know the model.
Understand the uncertainty.

A reference for your learning route, the Python runtime and the limits of a simulation.

Before you start

You should be able to read Python variables, function calls and a short loop. The course introduces arrays and probability as they become useful; it is not a complete Python syntax course. No prior Monte Carlo experience is needed for the core route. If probability is unfamiliar, start with optional lesson 0: probability essentials. It explains chance, independent attendance and a complete-event trial; its reading mark is separate from the 76-lesson progress count.

Start with 60 core investigations across ten modules. The initial reading, run and question usually take 6–11 minutes. The authored estimates total about 8 hours for the core; allow substantially more time to explore changes, debug and develop your capstone. Work in order initially; there are no prerequisite locks.

The optional advanced route adds 16 investigations (about 3 hours for an initial pass). It assumes the core and comfort with logarithms and basic probability densities. A density is a function integrated to obtain a region’s probability; its height is not a point probability. A cumulative distribution gives P(X ≤ x). Expectations integrate values against a density, or sum them against discrete probabilities. Logarithms turn products into sums, while ratios become differences of logs. Review these ideas before advanced sampling. The MCMC sequence first constructs a tractable posterior, then checks harder sampling algorithms against it.

The three optional workbooks apply the same habits to sizing/TCO, migration and GPU checkpoint economics. Their prices, capacities and policy effects are invented teaching inputs. The core capstone instead offers inventory, project-time and measurement investigations with CSV input and report export.

A fixed seed reproduces a pseudo-random calculation. More trials reduce numerical error under a model; they cannot establish whether that model describes reality. Monte Carlo supports a decision when the input evidence, model boundary and loss or service requirements are defensible.

You can read explanations, inspect code and view generated worked results without loading Python. JavaScript enables live code, feedback and saved drafts. No account or paid service is required.

Array operations at a glance

Start with lesson 2's executed two-event example. Arrays hold entries in an arrangement; a shape of (2,3) means two rows and three columns. Keep the unit of one row attached to the calculation.

x[:,0] and x[:3]
All rows of column zero; the first three rows. Numbering starts at zero.
sum(axis=1) / sum(axis=0)
One sum across each row / one sum down each column.
x * 2, x > 5
Multiply every entry by two; compare every entry with five. A boolean is True or False, counted as 1 or 0 in sums and means.
all / any
Every condition holds / at least one condition holds. Use the axis to retain the intended trial.
assert, array_equal, allclose
Stop if a stated check fails; compare arrays exactly; compare allowing small rounding differences.
ravel, reshape, column_stack
Flatten entries into one sequence; arrange the same entries into a shape; put sequences beside one another as columns. Shape changes must preserve the intended observations.

What actually runs?

CPython runs on your device through Pyodide 0.27.7 in a Web Worker. NumPy 2.0.2, SciPy 1.14.1, pandas 2.2.3 and Matplotlib 3.8.4 are real Python packages. Runtime files and dependency wheels are pinned, hash-checked during the build and served from this site. Inspect the runtime manifest.

Opening a page does not start Python. The first Run downloads a substantial runtime and package payload; allow time on slow connections. Browser caching helps subsequent runs, but full offline use is not provided. Each page has its own worker. A run starts with fresh user variables; imported modules remain loaded. During a new run or after an error, the page keeps the last successful result and its figures. Selected CSV input is written to data.csv for that run.

Stop terminates execution and the worker. The next Run creates a fresh runtime. Initialisation is limited to two minutes, execution to 45 seconds. Execution errors appear separately from the last successful result. Tools → Restore example opens the published code and keeps the most recently replaced draft under Recover draft. Notes and selected CSV stay in place.

Your source and CSV are not sent to a Python server. The site has no analytics or account backend. Python can still fetch network resources permitted by the browser; use code you understand.

Worked output and actual output

The build executes every published example to generate labelled worked results and plots. Your actual output appears only after running the editor. Numerical formatting can vary slightly across platforms. Native worked examples use the same NumPy, SciPy and pandas versions and Matplotlib 3.9.4; browser Matplotlib is 3.8.4. Inspect the build environment.

Formulas use locally hosted KaTeX 0.16.22; Python syntax stays literal. KaTeX licence. Reference illustrations explain published assumptions and examples. Your actual plots come from the executed source; phone and desktop versions use the same data.

Data provenance

Every investigation labels its invented or simulated inputs. No seed turns simulation into measurement. Capstone defaults are invented starter observations until you select a CSV. CSV validation checks structure: a UTF-8 file up to 1 MB with a value column and at least eight positive, finite numbers, with at least two different values. It does not establish independence, a representative sample or appropriate units. Choose the case in the code before uploading suitable observations.

Drafts and portable records

This browser saves code, predictions, notes, report fields, answer attempts and reading marks in local storage when it is available. They stay on this browser and origin; clearing site data removes them. Export progress and drafts from the overview; import replaces matching saved records. Reading marks record reading, not assessed understanding. Lesson 0 and workbook marks are saved but excluded from the 76-lesson progress count.

CSV inputs and results remain in memory on the current page. The run JSON preserves the last successful run’s exact code, input CSV, output, figures and package versions. The Markdown report includes the last successful run’s code, input CSV and output alongside the current report fields. You can edit the code, select a new input or retry a failed run while keeping that evidence. Keep your input CSV and run JSON alongside the Markdown report. Progress export does not include run results or CSV.

Run locally

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 an uploaded capstone case, put the CSV in the working directory as data.csv. Add plt.show() or plt.savefig("figure.svg") to view or save figures in a local script.

A working glossary

Use these short definitions as a reference alongside the lessons. The optional probability refresher is a useful starting point.

Independence
Learning one outcome does not change the modelled chance or distribution of another. It does not mean that both cannot occur.
Bias / consistency
Bias is systematic average estimation error across repeated runs at a fixed sample size. Consistency is approach to the target as the sample grows under the required conditions.
Covariance
The expectation of the product of deviations from each variable’s mean. For unit-SD variables it equals their linear correlation.
Trial
One complete simulated outcome for the question, including all inputs needed to calculate it.
Random variable
A quantity whose value varies under a probability model.
Distribution
A model specifying which values a quantity can take and their probabilities or densities.
Probability mass / density
For discrete values, probabilities at each value; for continuous values, a density whose integral over a region gives probability. A density value is not itself a point probability.
Expectation
The probability-weighted average under a model. An integral in continuous cases; a weighted sum in discrete cases.
Conditional distribution
A distribution specified after fixing or learning another quantity or condition.
Monte Carlo estimator
An approximation to an expectation, probability or integral using random samples and a stated calculation.
Outcome spread
Variation among possible outcomes within a model. More simulation trials do not make this underlying distribution narrower.
Monte Carlo standard error (MCSE)
Estimated numerical variability of a Monte Carlo estimator across repeated simulations. The formula depends on sampling and dependence.
Input / model uncertainty
Uncertainty about parameter values, input evidence or the structure and assumptions of the model.
Standard deviation
A measure of spread in a distribution, expressed in the quantity’s units.
Quantile
A boundary describing a stated fraction of a distribution; discrete and finite-sample conventions matter.
Confidence interval
A procedure with a repeated-sampling coverage target under its assumptions. It is not automatically an interval for future outcomes.
Correlation / dependence
Correlation describes a particular linear association. Dependence is broader: one quantity gives information about another. Zero correlation need not mean independence.
Scenario
A specified set of conditions to explore. Scenarios do not have probabilities unless a justified probability model assigns them.
Bootstrap
Resample observed units with replacement to approximate a sampling distribution. The unit and dependence structure matter.
Importance sampling
Sample a proposal distribution and use target-to-proposal density weights to estimate a target quantity. Support, overlap and finite moments matter.
Prior / likelihood / posterior
A parameter distribution before selected observations / the observation model as a function of parameters / the updated parameter distribution conditional on the evidence and model.
Markov chain
A sequence whose next state depends on its current state through a specified transition rule.
Stationary distribution
A distribution unchanged by a transition step when the current state has that distribution. Existence alone does not establish convergence from an arbitrary start.
Warm-up
An initial part of a chain used to move away from the starting state and, in some algorithms, adapt settings. Discarding it does not itself prove convergence.
Effective sample size (ESS)
A diagnostic expressed in independent-sample equivalents. Importance-weight ESS and Markov-chain ESS measure different features. Neither alone guarantees target coverage.
R-hat
A multi-chain agreement diagnostic. The course implements rank-normalised and folded split R-hat, following Vehtari et al.; near-one values cannot rule out jointly missed modes.
Posterior predictive
The distribution of future or replicated observations obtained by averaging their conditional distribution over the posterior parameter distribution.

Sources & acknowledgements

The Monte Carlo examples and exercises are authored for this course. The small-investigation structure draws on the author’s Assembly Lab; the readable visual shell and learning workflow draw on Scientific Method Lab; the editor and worker pattern draws on Event Streaming Lab. Code is Apache-2.0, original prose CC BY-NC 4.0. Fonts and Python packages retain their distributed licences.

References support the mathematical methods; they do not establish this course’s learning effectiveness. Author review and automated native/browser execution are documented in the repository. The course has not been evaluated with novice learners.

Scope for further study

The examples are small inspectable models. Advanced modules introduce methods, not a production probabilistic programming system. Further work includes rigorous tail and quantile error estimation, sequential precision procedures, nested parameter uncertainty, discrete-event simulation frameworks, Hamiltonian Monte Carlo, full modern bulk/tail ESS, multimodal targets, model selection and domain-specific validation.

Back to the investigations ↗