Quantum theory predicts probability distributions for measurement outcomes. One result is a sample, not a percentage. The distribution becomes testable only when you prepare comparable states many times and compare the long-run frequencies with the model.
For mutually exclusive outcomes k, the Born rule is
The square is crucial. If outcome amplitudes have magnitudes 1 and 2, their weights are 1 and 4, so the normalized probabilities are 0.2 and 0.8—not 1/3 and 2/3. First normalize; then sample:
const probabilities = normalizeWeights(amplitudes.map((amplitude) => amplitudeMagnitudeSquared(amplitude)));
const outcome = sampleCategorical(probabilities, random);
sampleCategorical should return an index from the supplied outcomes, even at the top edge of its random interval. Its unit tests reject an all-zero distribution and verify that every seeded sample is legal. Those are contract tests, not a claim about the interpretation of quantum measurement.
Set two real amplitude magnitudes. The model squares and normalizes them, then makes 100 seeded measurement draws so the same inputs always give the same sample.
Outcome 0
48 observed / 100; prediction 50.0%
Outcome 1
52 observed / 100; prediction 50.0%
Predicted outcomes: 0 → 50.0%, 1 → 50.0%. This repeatable sample observed 48 zeros and 52 ones.
The lab uses real amplitude magnitudes to keep the calculation visible. Relative phase matters whenever alternatives can interfere before measurement; this two-outcome display deliberately starts after the state has been expressed in a selected measurement basis. Its 100-draw frequency is allowed to differ from the probability. Run it conceptually with 10, 100, and 10,000 trials: larger ensembles normally make random fluctuations relatively smaller, but no finite run has to reproduce an exact percentage.
Prediction: Doubling one amplitude magnitude does not double its probability; it quadruples its unnormalized weight.
Set both amplitude magnitudes to 1.0 and predict the result. Then change outcome 1 to 2.0, predict its probability before reading the status, and compare the 100-draw count with 80 expected draws. Explain why a different seed could give another valid count.Measurement code should make each transformation visible: amplitudes produce squared weights, weights normalize to probabilities, and a sampler produces one permitted outcome. Test the normalization and legality contracts, then compare an ensemble—not one draw—with the predicted distribution.
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 Measurement and Probability, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Quantum Beginnings, 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 Measurement and Probability 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.
Normalize quantum probabilities, sample with seeds, and compare ensembles with theoretical predictions.