Measurements are input data with a confidence range, not perfectly known constants. A Monte Carlo program repeats the same calculation with many plausible inputs and records the output distribution.
For a distance measured from a constant speed and duration:
\[d = vt\]If both v and t carry uncertainty, a single calculated distance hides useful information. Instead, sample a possible velocity and time, calculate d, and repeat. The resulting values make the uncertainty visible as data.
const distances = Array.from({ length: 10_000 }, () => {
const velocity = sampleNormal(5.0, 0.1);
const time = sampleNormal(12.0, 0.2);
return velocity * time;
});
The program is not discovering a new physical law. It is checking how sensitive an existing relationship is to imperfect inputs. Keep units beside values and set a random seed in tests so a surprising result can be reproduced.
Prediction: Doubling the uncertainty in time makes the output distances spread farther apart when speed uncertainty stays fixed.
Run the thought experiment with a fixed seed. First use a 0.2 s time uncertainty, then 0.4 s. Before looking at the output, predict which summary—the average or the spread—should change most.Monte Carlo propagation turns uncertain inputs into a distribution of possible outputs. Reproducible sampling and a zero-uncertainty case are practical tests of the implementation.
sampleNormal make?Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.
\[\text{observable output} = f(\text{inputs},\,\text{state})\]For Propagation of Uncertainty, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Measurement, Units, and Uncertainty, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.
Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.
This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.
Treat Propagation of Uncertainty as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.
Use repeated samples to see how uncertain inputs spread into a calculated result.