Learn a centered cross-moment from sibling values whose item-level pairing carries the answer.
Seed 3508 on gpu: 5 of 5 behavioral checks met. See the measurements below. The experiment code has changed since this run; these measurements describe its earlier version.
Insights
Covariance depends on which X belongs with which Y, not just the two value distributions. Circularly shifting only Y preserves both marginal sets of numbers but breaks accuracy against the original covariance labels. That is evidence that the model uses item-level pairing.
Keep aligned fields on the same repeated item so their relationship remains available before aggregation. The supplied-cross-product control helps distinguish that interaction from the final averaging step. This proof supports learned population covariance in its tested setting; it does not establish Pearson correlation, which also requires normalization by both spreads. Complete-pair permutation and varying collection lengths remain separate checks.
Setup
Code
"""Aligned sibling fields should support covariance.Learn the centered cross-moment and respond to pairing corruption.Run: uv run python proofs/run.py P006"""from __future__ import annotationsfrom collections.abc import Iteratorfrom copy import deepcopyimport lightning.pytorch as litimport numpy as npimport torchfrom reporting import reportimport relflow as rfPROOF_ID ="P006"ITEMS =8
Examples
Targets use mask=True; the labels below are supervision hidden from the encoder.
Negating Y changes the population covariance to −0.8.
Shift only Y
items:-{x:-1,y:1.4}-{x:1,y:-1.4}-{x:-1,y:0.2}-{x:1,y:-0.2}-{x:-1,y:1.4}-{x:1,y:-1.4}-{x:-1,y:0.2}-{x:1,y:-0.2}covariance:0.8 # Retained original label
A one-position circular shift preserves both marginal value sets but makes the visible covariance −0.8. The corruption retains the original 0.8 target to test whether predictions depend on pair alignment.
Synthetic data and controls
Code
def covariance_records(*, rows: int, seed: int) -> Iterator[dict]:"""Draw paired fields with controlled means, scales, and covariance.""" rng = np.random.default_rng(seed)for _ inrange(rows): x_basis = rng.normal(size=ITEMS) x_basis -= x_basis.mean() x_basis /= np.sqrt(np.mean(np.square(x_basis))) orthogonal = rng.normal(size=ITEMS) orthogonal -= orthogonal.mean() orthogonal -= np.mean(orthogonal * x_basis) * x_basis orthogonal /= np.sqrt(np.mean(np.square(orthogonal))) correlation =float(rng.uniform(-0.88, 0.88)) y_basis = correlation * x_basis + np.sqrt(1.0- correlation * correlation) * orthogonal x_scale =float(rng.uniform(0.35, 1.45)) y_scale =float(rng.uniform(0.35, 1.45)) x_location =float(rng.uniform(-0.8, 0.8)) y_location =float(rng.uniform(-0.8, 0.8)) x_values = x_location + x_scale * x_basis y_values = y_location + y_scale * y_basisyield {"items": [{"x": float(x), "y": float(y)} for x, y inzip(x_values, y_values, strict=True)],"covariance": correlation * x_scale * y_scale,"correlation": correlation, }def shuffle_y(observations: list[dict], *, seed: int) ->list[dict]:"""Break within-row pairing while preserving every marginal value.""" rng = np.random.default_rng(seed) rows = deepcopy(observations) changed =0for row in rows: items = row["items"] offset =int(rng.integers(1, len(items))) shifted = np.roll([item["y"] for item in items], offset) changed +=sum((item["y"] != y for item, y inzip(items, shifted, strict=True))) row["items"] = [{"x": item["x"], "y": float(y)} for item, y inzip(items, shifted, strict=True)]if changed ==0:raiseValueError("pair shuffle did not change any item-local associations")return rowsdef prediction(model: rf.Model, observations: list[dict]) -> np.ndarray: inputs = [{"items": row["items"]} for row in observations] output = model.predict(inputs)["predictions"].to_pylist()return np.asarray([row["record/covariance"]["content"] for row in output], dtype=np.float64)def rmse(actual: np.ndarray, predicted: np.ndarray |float) ->float:returnfloat(np.sqrt(np.mean(np.square(actual - predicted))))def score(*, train: list[dict], test: list[dict], predicted: np.ndarray) ->dict[str, float]:"""Compare held-out RMSE with the constant training-target mean.""" actual = np.asarray([row["covariance"] for row in test], dtype=np.float64) baseline = rmse(actual, float(np.asarray([row["covariance"] for row in train], dtype=np.float64).mean())) measured = rmse(actual, predicted)return {"rmse": measured, "baseline_rmse": baseline, "nrmse": measured / baseline}
Model tree
Figure 1: Item attention mixes aligned X and Y fields while the branch keeps every token for learned covariance decoding.
How it works
The repeated branch keeps x and y together and uses reduction=None to preserve their encoded coordinates. Learned root attention can combine that evidence before scalar decoding. Independent locations, scales, and a random correlation coefficient prevent either marginal alone from supplying covariance.
The negative control circularly shifts only y, preserving the exact values in both fields but breaking their alignment. Labels stay unchanged, so error must increase when the model responds to the changed pairs. The target is population covariance, the mean centered product; Pearson correlation is not tested here. Supplied cross-deviations isolate its reduction.
Repeat across seeds and check complete-pair permutation. Variable lengths, missing values, zero variance, and correlation normalization remain separate questions. Coordinate-mixing ablations would distinguish which mechanisms are necessary for the observed result.
The family’s promotion target is at least three core seeds and ten lightweight calibration seeds.
Reproduce
Run by stable ID from the repository root:
uv run python proofs/run.py P006
Or run the self-contained script directly:
PYTHONPATH=proofs uv run python proofs/aggregation/aligned_pair_covariance.py
Add --accelerator gpu for CUDA or --seed 42 for another seeded experiment. --steps 2 checks execution with a short training budget; it is recorded as a smoke run.