Lecture 09: Monte Carlo Transport and Random Walks
How many photon histories are required to resolve a transmission probability?
14-week course · 3 credits · Week 9
Motivation
How many photon histories are required to resolve a transmission probability?
Monte Carlo estimates expectations by sampling a probability law. Independent Bernoulli transmission trials have standard error approximately sqrt[p(1-p)/N], so precision improves only as N^-1/2.
Today’s result must be interpretable as a physical statement with declared data, algorithm, uncertainty, and a check that could fail.
Learning objectives
After this lecture, you can
How many photon histories are required to resolve a transmission probability?
Use NumPy Generator with an explicit seed
A fixed seed reproduces a stream only within a compatible software/bit-generator setup; NumPy does not guarantee stream compatibility across versions. Seed and package versions are both part of provenance.
Core language
Terms for This Lecture
Monte Carlo estimator
Definition: A sample-derived statistic used to approximate an expectation or probability.
Why it matters here: It helps answer How many photon histories are required to resolve a transmission probability? within the numerical model described here.
Relationships: Connect it to Random seed, the governing expression \(\hat p=\frac{k}{N},\quad SE(\hat p)=\sqrt{\frac{\hat p(1-\hat p)}{N}}\), and the computed diagnostic developed later in the lecture.
Boundary or common confusion: A fixed seed reproduces a stream only within a compatible software/bit-generator setup; NumPy does not guarantee stream compatibility across versions. Seed and package versions are both part of provenance.
Random seed
Definition: An input that initializes a pseudorandom number generator and supports repeatable streams.
Why it matters here: It helps answer How many photon histories are required to resolve a transmission probability? within the numerical model described here.
Relationships: Connect it to Bernoulli trial, the governing expression \(\hat p=\frac{k}{N},\quad SE(\hat p)=\sqrt{\frac{\hat p(1-\hat p)}{N}}\), and the computed diagnostic developed later in the lecture.
Boundary or common confusion: A fixed seed reproduces a stream only within a compatible software/bit-generator setup; NumPy does not guarantee stream compatibility across versions. Seed and package versions are both part of provenance.
Bernoulli trial
Definition: A two-outcome random experiment represented by zero or one.
Why it matters here: It helps answer How many photon histories are required to resolve a transmission probability? within the numerical model described here.
Relationships: Connect it to Standard error, the governing expression \(\hat p=\frac{k}{N},\quad SE(\hat p)=\sqrt{\frac{\hat p(1-\hat p)}{N}}\), and the computed diagnostic developed later in the lecture.
Boundary or common confusion: A fixed seed reproduces a stream only within a compatible software/bit-generator setup; NumPy does not guarantee stream compatibility across versions. Seed and package versions are both part of provenance.
Standard error
Definition: The sampling standard deviation of an estimator across repeated independent datasets.
Why it matters here: It helps answer How many photon histories are required to resolve a transmission probability? within the numerical model described here.
Relationships: Connect it to Convergence rate, the governing expression \(\hat p=\frac{k}{N},\quad SE(\hat p)=\sqrt{\frac{\hat p(1-\hat p)}{N}}\), and the computed diagnostic developed later in the lecture.
Boundary or common confusion: A fixed seed reproduces a stream only within a compatible software/bit-generator setup; NumPy does not guarantee stream compatibility across versions. Seed and package versions are both part of provenance.
Convergence rate
Definition: The scaling of estimator uncertainty with sample size, here typically proportional to N to the minus one-half.
Why it matters here: It helps answer How many photon histories are required to resolve a transmission probability? within the numerical model described here.
Relationships: Connect it to Monte Carlo estimator, the governing expression \(\hat p=\frac{k}{N},\quad SE(\hat p)=\sqrt{\frac{\hat p(1-\hat p)}{N}}\), and the computed diagnostic developed later in the lecture.
Boundary or common confusion: A fixed seed reproduces a stream only within a compatible software/bit-generator setup; NumPy does not guarantee stream compatibility across versions. Seed and package versions are both part of provenance.
Physical and mathematical model
State what is being evolved
Monte Carlo estimates expectations by sampling a probability law. Independent Bernoulli transmission trials have standard error approximately sqrt[p(1-p)/N], so precision improves only as N^-1/2.
Define the state, coordinates, units, initial/boundary conditions, and domain before interpreting solver output.
Numerical method
Algorithm choice is a modeling decision
Use NumPy Generator with an explicit seed; generate exponential interaction distances or Bernoulli transmission outcomes; calculate uncertainty; repeat at increasing N; report seed, estimator, and stopping criterion.
Write the model and its assumptions.
Choose a solver and identify its stability, accuracy, and conservation properties.
Record configuration, tolerances or timestep, and output sampling.
Compare against an analytic limit, independent method, or controlled refinement.
Visual reasoning
Seeded photon histories through a slab
Seeded sample paths visualize stochastic histories; the transmission estimate and sampling error come from the separate Bernoulli experiment.
Computed example
One result, with a check
For tau=2, analytic transmission is 0.135335; the seeded N=20000 estimate is 0.137800 +/- 0.002437 (one standard error).
Inputs and method are generated by src/astr474_computations.py; the machine-readable values are in data/generated/computed_results.json.
A fixed seed reproduces a stream only within a compatible software/bit-generator setup; NumPy does not guarantee stream compatibility across versions. Seed and package versions are both part of provenance.
Verification
What would falsify this result?
Repeat with a smaller timestep, tighter tolerance, or finer spatial grid.
Track conservation or residual structure in addition to visual agreement.
Check units, coordinate frame, boundary conditions, and invariants independently.
Change a random seed when the method is stochastic; report the resulting sampling uncertainty.
Do not report a smoother curve as proof of convergence.
Failure modes
Numerical agreement has a domain
A fixed seed reproduces a stream only within a compatible software/bit-generator setup; NumPy does not guarantee stream compatibility across versions. Seed and package versions are both part of provenance.
Solver error, discretization error, stochastic error, parameter uncertainty, and model discrepancy are different quantities. Diagnose and report them separately.
Active reasoning
Make a prediction before rerunning
How many photon histories are required to resolve a transmission probability?
State a measurable outcome, a competing explanation, and the smallest computation that distinguishes them. Include an expected direction or scaling, then test it.
Workflow
From parameters to auditable output
Use NumPy Generator with an explicit seed; generate exponential interaction distances or Bernoulli transmission outcomes; calculate uncertainty; repeat at increasing N; report seed, estimator, and stopping criterion.
Record the exact command, package versions, data path, random seed if applicable, and output checksum. Keep raw inputs unchanged and generated files separate.
Transfer
Lab and problem-set connection
Lab 06 measures seeded transmission convergence and checks whether the known analytic probability lies within sampling uncertainty.
Submit plots with labeled axes/units, a concise uncertainty argument, and enough code or intermediate values for a peer to reproduce the claim.
Synthesis
Three durable checks
Does the implemented equation match the intended physical model?
Does the numerical result converge under a controlled method change?
Does the interpretation stay inside the validity and provenance limits?
A fixed seed reproduces a stream only within a compatible software/bit-generator setup; NumPy does not guarantee stream compatibility across versions. Seed and package versions are both part of provenance.