# Part 5 ridge curves

`../../assets/sensor-ridge-sweeps.js` contains compact plotted summaries of 1,024 independent sensor racks for each preset. Every integer sensor count from 1 through 100 is present, followed by logarithmic spacing to 4,000 sensors. Sensor columns are nested within each rack: increasing the count adds independent noise columns while retaining existing readings and ordinary, unnormalized Gaussian labels. Gaussian noise is rotation invariant, so the response vector can be fixed to `(1,…,1)` with squared norm equal to the sensor count. This is the same physical model as the earlier figures.

The population squared error is `(a·w−1)²+v‖w‖²`. A thin singular-value decomposition evaluates this expression and its derivative analytically along the span ridge path. One common multiplier of each rack’s smallest nonzero Gram eigenvalue is selected at each width to minimize the median population error, preserving the original comparison convention. The training cost is evaluated at that same multiplier. The headline training curves use each rack’s training MSE divided by its own mean squared training label, then take the median; thus predicting zero is exactly 1. Raw training-MSE medians are retained in the fixture for audits. The fixture stores separate positive-only and signed optima on these exact same racks. The Part 5 buttons change all three panels using those summaries; they do not change the samples or tuning objective. `positiveRidge`, `positiveLambda` and `positiveRidgeTrain` are the positive-only fields; the existing `ridge`, `lambda` and `ridgeTrain` fields allow negative shifts.

`interpTrainRatio`, `ridgeTrainRatio`, and `positiveRidgeTrainRatio` hold the normalized summaries. `python3 blog/data/sensor-fixtures/generate-ridge.py --add-training-ratios` replays the original seeded racks and stored penalties, verifies their raw training medians, and adds only those ratio fields. It preserves the original raw fields, population risks, and selected penalties. Full regeneration also includes the ratio fields.

The entire positive domain is represented by `t=f/(1+f)`, including the exact zero predictor at `t=1`. There is no finite positive penalty cap. Stationary points are solved from the analytic derivative, and bounded refinement handles changes in the pair of racks that define the median. Analytic interval bounds then refine any remaining interval that could improve the median risk by more than `5e−7`, giving a numerical global-optimality tolerance across both domains. Chebyshev intervals bracket roots; their endpoints are not a candidate penalty grid. The analytic interval bound and adaptive subdivision give a numerical optimization tolerance of 5e−7 for the sampled median. This is an optimization tolerance, not an estimate of sampling uncertainty. Negative multipliers remain strictly above the first Gram pole at −1. Numerical checks compare the continuous result with the old grid and with many more initial root brackets. The default curves have finite optima. Minimum-norm training error is stored as exactly zero at every width where interpolation is possible.

Reproduce the compact fixture using Python 3, NumPy and SciPy:

```sh
python3 blog/data/sensor-fixtures/generate-ridge.py
python3 blog/tests/sensor-ridge-numerics.test.py
node --test blog/tests/sensor-ridge-sweeps.test.cjs
```

The generator records the seed policy and source hash in the fixture’s `provenance` property. All racks contribute; no rejection, filtering, replacement, clipping, seed search or smoothing is used. The fixture stores median and quartile curves rather than raw rack archives, so the browser performs no costly Monte Carlo calculations and Git receives no additional sample archive. On phones the renderer uses compact SVG layouts with stacked legends, displaying the entire sensor-count range without horizontal clipping. A missing or malformed ridge fixture displays an unavailable state in Part 5 while the independently modeled Parts 1 and 2 remain usable.
