Chapter 11

Computing with Arrays

Carry one small measurement table through calibration, named broadcasting, centering, weighted scores, and checks that keep its values and axes visible.

Chapter 10 established the observation-by-sensor structure: we could name its axes, select and reshape it, summarize it, and inspect storage relationships. Here we switch to smaller values while keeping the same `(3, 2)` structure, so each calibration and centered score can be checked by hand.

We begin by applying one calibration formula at every position. Per-sensor and per-observation values then introduce broadcasting through named axes rather than abstract shape tricks. A reduction and a broadcast work together to center each sensor column, with the result checked against a hand calculation and a near-zero mean.

A loop serves as a reference for the whole-array expression. From there, visible products and sums build one weighted score and then several scores. The final lesson checks the complete pipeline for expected shapes, axis meanings, finite values, centered means, and one result calculated by hand. Formal linear algebra comes later; this chapter keeps the executable calculation inspectable.

After this chapter

  • Apply one formula at every array position while predicting a value, the result shape, and the dtype.
  • Align scalar, per-sensor, and per-observation data by comparing dimensions from the right and naming their axes.
  • Center sensor columns with a reduction and broadcast, then verify the result by hand and with a tolerance-aware check.
  • Compare a loop with its whole-array equivalent and choose an exact or floating-point comparison deliberately.
  • Expand one weighted sum before using @ to compute one score per observation.
  • Treat each weight column as another weighted score, preserve operation order, and add one bias per output.
  • Verify a composed numerical pipeline through shapes, named axes, finite values, invariants, and expected results.

Lessons

  1. 01
    Transform Every Value

    Read whole-array arithmetic as the same small calculation applied at every position.

    3 exercises
  2. 02
    Align Arrays with Broadcasting

    Compare dimensions from the right while keeping shape compatibility separate from semantic correctness.

    3 exercises
  3. 03
    Center and Check Measurements

    Combine an axis reduction with broadcasting in one useful, hand-checkable numerical task.

    3 exercises
  4. 04
    Express a Checked Array Computation

    Treat a whole-array expression as verified equivalent work, not as a rule that loops are bad.

    3 exercises
  5. 05
    Compute a Weighted Score

    Derive `@` from visible products and sums with matching inner sizes.

    3 exercises
  6. 06
    Compute Several Weighted Scores

    Track observation, sensor, and output axes while preserving multiplication order and checking one result by hand.

    3 exercises
  7. 07
    Verify a Numerical Pipeline

    Verify a composed calibration, centering, and weighted-score pipeline instead of trusting successful execution.

    3 exercises

Review and practice

  1. Review

    Review every operation through visible values, axis meanings, result shapes, and a suitable numerical check.

  2. Exercises

    Apply the complete Chapter 11 path through ten cumulative prediction, calculation, implementation, and diagnosis exercises.

Chapter progress