Review

Reconstruct bounded variation, generator replay, explicit sampling, aligned splitting, saved run evidence, and comparison as one repeatable experiment.

Start with the Variation Contract

Random-looking output should still follow stated rules. For the measurement experiment, the noise contract is:

shape: (3, 2)
lower bound: -0.2, included
upper bound: 0.2, excluded

The generator call can produce many valid arrays. Property checks establish that one result follows the contract:

These checks do not predict the particular values. They check what every acceptable draw must satisfy.

Replay the Same Ordered Calls

np.random.default_rng(seed) creates a generator at a starting state. Each draw changes that state. Recreating a run therefore needs more than the seed:

generator algorithm + seed + ordered calls → generated values

Two generators created with the same seed and given the same calls in the same order produce the same sequence. An extra draw changes every later position in that sequence. Pass one generator into functions that need variation, rather than hiding a new generator or repeatedly reseeding inside them.

State a Sampling Rule

A sample needs four pieces of information:

  • the available population;
  • the requested sample size;
  • whether a selected position can be selected again; and
  • the selected indexes.

Indexes preserve identity. If measurement row i belongs to record ID i, apply the same sampled index array to both arrays. With replacement, an index may appear more than once. Without replacement, every selected index must be distinct and the requested size cannot exceed the population size.

Use One Permutation for Every Paired Array

A permutation contains each original position exactly once in a new order. Apply it to every aligned array:

Split the ordered indexes at an explicit boundary to create a working group and a held-back checking group. Verify three properties:

  1. the groups do not share an index;
  2. recombining them covers every original index exactly once; and
  3. each record ID remains paired with its original reading.

This chapter does not assign statistical meaning to the two groups. Later subjects will define training, validation, testing, and domain-specific split rules.

Record Settings, Measurements, and Artifacts

A saved run should distinguish what was chosen from what was observed.

PartExamples
configurationseed, noise bounds, sample count
measurementmean, selected indexes, generated values
artifactfigure or result-file path

Dataclasses can keep configuration and result fields named. asdict converts their structure, but NumPy arrays and scalar values still need ordinary Python forms before JSON can store them:

Write the record, read it back, and inspect a compact preview. A saved file is evidence only when its fields retain enough meaning to reconstruct the run.

Define Agreement before Comparing

Check the saved configuration before comparing outputs. A reproduction uses the same settings and call sequence. Discrete values such as selected indexes should match exactly. Floating-point results should use np.allclose when small numerical rounding differences are acceptable.

If a comparison fails, find the first mismatch rather than reporting only False. Check the configuration, then call order, shapes, discrete outputs, and numerical values.

A reproduction tries to repeat the same run. A controlled comparison changes one named setting on purpose and holds the others fixed. Different outputs in the second case are expected; the record must make the changed setting visible.

Retain the Complete Experiment Path

You can now explain one controlled numerical experiment:

fixed measurements
  → stated variation contract
  → generator, seed, and ordered calls
  → sampled or permuted indexes
  → aligned records
  → saved configuration, measurements, and artifact
  → replay and explicit comparison

A seed controls one generator sequence. It does not record input files, code, package versions, hardware, or every environmental source of numerical difference. The experiment is repeatable because its relevant choices and evidence are explicit, not because one seed guarantees everything.

Pause and reflect

What can you now explain without looking back, and what should you revisit? The note stays with this review.

Review

Not marked done.