Skip to content

Commit d09544b

Browse files
aurascoperclaude
andcommitted
docs: add cross-project measurement primitives (Math §11) + Research upgrades
- docs/Math.md §11 (new): unifies the measurement *instruments* across the awake NeuralCompose pipeline, the WorldModel JEPA spike, and the D8 sleep study — (PR, α) eigenspectrum descriptors + RankMe; aperiodic-adjusted spectral features (specparam: χ as a first-class feature, aperiodic-removed band power, corrected alpha dropout r_α^corr); the participation-ratio trajectory-novelty functional N_PR (unifying decoder loop count §8, JEPA collapse, and analogy novelty); the pilot-N cross-representation-alignment caveat; and explicit boundaries. - docs/Research.md: the §11 upgrades it calls for — the aperiodic-exponent (χ ↔ insight) hypothesis is now pre-registerable, not a post-hoc theta correlation; N_PR added as an automated novelty companion with a pre-registered Spearman ρ vs. blind human novelty; EEG↔language alignment deferred out of pilot N (n≯d regime), both Procrustes variants reported when run. - README.md: fix a truncated sentence in the playback-math section; note OSC as a live-acquisition clock alongside BLE; point to Math §11. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MprrYMDxCHVsP8UiHkwBBx
1 parent d21f095 commit d09544b

3 files changed

Lines changed: 141 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ principles.
176176

177177
## Playback & synchronization math
178178

179-
Live BLE acquisition is a noisy clock — inter-sample gaps jitter with radio
179+
Live acquisition is a noisy clock — inter-sample gaps jitter with radio
180+
conditions and OS scheduling (over BLE), or with network latency (a remote
181+
Muse streamed over OSC), so recorded timestamps never land on a perfect grid.
180182
`PlaybackEEGStream.normalized` resamples a recording onto an
181183
exact uniform grid before replay, via linear interpolation between the
182184
two nearest recorded samples $(t_a, x_a)$, $(t_b, x_b)$:
@@ -283,7 +285,12 @@ $$
283285
where $r_n$ is the repeat count for period $n$. Decoder stability
284286
additionally records loop period and repeat count.
285287

286-
For complete derivations and notation, see [`docs/Math.md`](docs/Math.md).
288+
For complete derivations and notation, see [`docs/Math.md`](docs/Math.md) —
289+
including §11, the cross-project measurement primitives ($(\mathrm{PR}, \alpha)$
290+
eigenspectrum descriptors, aperiodic-adjusted spectral features via specparam,
291+
and the trajectory-novelty functional $N_{\mathrm{PR}}$) that tie the awake
292+
pipeline, the WorldModel JEPA spike, and the sleep study to one shared set of
293+
instruments — and its companion upgrades in [`docs/Research.md`](docs/Research.md).
287294

288295
## Repository layout
289296

‎docs/Math.md‎

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,132 @@ Recommended evaluation reports include:
201201
- hypothesis preregistration
202202

203203
These sections align with the Stage 3.4 and Stage 3.5 evaluation
204-
framework.
204+
framework.
205+
206+
## 11. Cross-Project Measurement Primitives
207+
208+
Companion to §2–3, §8, and §9 above and to `Research.md`, drawing on the
209+
representation-geometry / spectral-preprocessing review.
210+
211+
**Scope rule.** This section unifies *instruments*, not *theories*. Every
212+
definition below must change a reported number in at least one project; nothing
213+
here justifies an algorithm change on its own (cf. "philosophy is documentation,
214+
never justification"; "no speculative abstraction unless ≥2 call sites exist").
215+
No shared latent space is asserted — heterogeneous embeddings remain coupled,
216+
not fused (§7 stays deferred).
217+
218+
### 11.1 Eigenspectrum descriptors — (PR, α) as a pair
219+
220+
Given a representation matrix $Z \in \mathbb{R}^{n \times d}$ with centered
221+
covariance eigenvalues $\lambda_1 \ge \dots \ge \lambda_d \ge 0$:
222+
223+
- **Participation ratio (second-moment effective dim; = §9.4):**
224+
$$\mathrm{PR}(Z) = \frac{\left(\sum_i \lambda_i\right)^2}{\sum_i \lambda_i^2}$$
225+
226+
- **RankMe (entropy effective dim):** with singular values $\sigma_k$ of $Z$ and
227+
$p_k = \sigma_k / \sum_j \sigma_j + \varepsilon$,
228+
$$\mathrm{RankMe}(Z) = \exp\!\Big(-\sum_k p_k \log p_k\Big)$$
229+
230+
- **α-ReQ (eigenspectrum decay slope):** fit $\lambda_i \sim i^{-\alpha}$ by OLS
231+
of $\log\lambda_i$ on $\log i$.
232+
233+
**PR and RankMe are the same family** (Simpson vs. Shannon summaries of the same
234+
spectrum); **α is orthogonal** to both — it measures *shape*, not magnitude. Two
235+
representations can share PR while differing in α.
236+
237+
**Use.** Report every representation in the stack — per-user EEG latent, each
238+
embedding model in `embedding_space_analysis.py`, the synthetic JEPA latent — as
239+
the pair $(\mathrm{PR}, \alpha)$. The generalization-favorable regime is near
240+
$\alpha \approx 1$ (α-ReQ; verify the exact interval before citing a number — it
241+
rests on companion benign-overfitting theory, not a single sentence in the
242+
source).
243+
244+
**Caveat (inherited).** PR/RankMe are bounded by $\min(n-1, d)$; at $n \approx d$
245+
(e.g. $n=10$) both reflect the sample-to-dimension ratio, not geometry. See §9.4.
246+
247+
### 11.2 Aperiodic-adjusted spectral features (specparam)
248+
249+
Replace/augment the raw band power of §2 and the alpha ratio of §3. Fit the
250+
log-power spectrum as an aperiodic component plus periodic peaks (specparam /
251+
FOOOF, "fixed" aperiodic mode):
252+
$$\log_{10}\hat S(f) \approx \underbrace{b - \chi\,\log_{10} f}_{\text{aperiodic } \hat L(f)} \;+\; \sum_j \mathcal{G}_j(f)$$
253+
so in linear power $\hat L(f) = 10^{b} f^{-\chi}$.
254+
255+
- **Aperiodic exponent $\chi$ is a first-class feature** (this is the "1/f slope"
256+
the whole preprocessing question turns on) — not a nuisance to be log-compressed
257+
away.
258+
- **Aperiodic-adjusted band power** (the oscillatory signal, aperiodic removed):
259+
$$P_b^{\mathrm{osc}} = \int_{f_1}^{f_2} \big[\hat S(f) - \hat L(f)\big]_+ \, df$$
260+
- **Corrected alpha dropout (§3 upgrade):** compute $r_\alpha$ from
261+
$P_\alpha^{\mathrm{osc}}$ (aperiodic-removed alpha), so a broadband aperiodic shift
262+
no longer masquerades as an alpha change:
263+
$$r_\alpha^{\mathrm{corr}} = P_\alpha^{\mathrm{osc}} / P_{\alpha,\text{baseline}}^{\mathrm{osc}}, \qquad r_{\alpha,\mathrm{dB}}^{\mathrm{corr}} = 20\log_{10} r_\alpha^{\mathrm{corr}}$$
264+
265+
**Serves both stacks.** Same front-end for the awake NeuralCompose pipeline and
266+
the sleep study's EEG. **`Research.md` upgrade:** the exploratory hypothesis
267+
"theta power ↔ dream relevance" becomes "aperiodic exponent $\chi$ during N2/SWS
268+
↔ insight quality" — literature-backed (aperiodic slope indexes E/I balance and
269+
varies across sleep stages), hence pre-registerable rather than post-hoc.
270+
271+
**Decision (transform choice), most→least information-preserving:** (1) specparam
272+
channels $\{\chi, b, P_b^{\mathrm{osc}}\}$; (2) learned/affine normalization or
273+
symlog for scale-robustness; (3) log band power (current — conflates periodic +
274+
aperiodic; keep only if a forward benchmark beats 1–2); (4) aggressive 1/f
275+
flattening (only if a forward benchmark shows the aperiodic component is nuisance
276+
for the task). Never default to (4).
277+
278+
### 11.3 Trajectory novelty / collapse functional
279+
280+
Unifies §8 (decoder loop count $D$), JEPA representation collapse, and the
281+
`Research.md` novelty outcome. For a trajectory of states
282+
$\tau = (\tau_1,\dots,\tau_T)$ with centered covariance eigenvalues $\lambda_i$:
283+
$$N_{\mathrm{PR}}(\tau) = \frac{\left(\sum_i \lambda_i\right)^2}{\sum_i \lambda_i^2}$$
284+
Low $N_{\mathrm{PR}}$ ⇒ the generative/predictive rollout occupied a
285+
low-dimensional subspace (collapse / looping). Three instantiations:
286+
287+
| Project | Trajectory states $\tau_t$ | Interpretation |
288+
|---|---|---|
289+
| WorldModel (JEPA) | rolled-out latent states | low $N_{\mathrm{PR}}$ = degenerate dynamics; soft companion to VICReg variance floor |
290+
| NeuralCompose decode (§8) | emitted-token embeddings | $D$ is the exact-repeat corner; $N_{\mathrm{PR}}$ also catches paraphrastic near-loops ($D{=}1$ but $N_{\mathrm{PR}}\!\approx\!2$–3). $N_{\mathrm{PR}} \supseteq D$ in coverage |
291+
| Sleep study (D8) | LLM-extracted analogy embeddings | effective count of *distinct* analogical directions |
292+
293+
**`Research.md` contribution (pre-register before D8):**
294+
- Report $N_{\mathrm{PR}}$ over the analogy set as an **automated novelty score**,
295+
secondary to the blind human Likert (H1).
296+
- Pre-register **Spearman $\rho(N_{\mathrm{PR}}\text{-novelty}, \text{mean blind
297+
human novelty})$** and report it beside the LLM–human agreement of H4.
298+
- Optionally: does $N_{\mathrm{PR}}$ separate Active vs. Control? (automated
299+
companion to H1.)
300+
301+
Passes the "must change a measured number" bar in all three projects
302+
simultaneously.
303+
304+
### 11.4 Cross-representation alignment — pilot-scale caveat
305+
306+
The §9 metrics (CKA, SVCCA, scaled/orthogonal Procrustes) answer the review's
307+
"are the EEG latent and the language/solution latent *coupled* spaces?" question
308+
directly. **Do not run this at pilot N.**
309+
310+
With $n \approx 20$–$30$ matched (EEG-state, solution-embedding) pairs and $d$ in
311+
the hundreds, we are in the $n \not\gg d$ regime where §9's own caveat (and
312+
Kornblith et al.; Davari et al.) says CKA/SVCCA cannot be trusted. Required
313+
before any alignment claim:
314+
1. Reduce each space to $k \ll n$ dimensions first (the SVCCA $\tau$-truncation
315+
of §9.2), then compare; **or**
316+
2. Defer the EEG↔language coupling analysis to the definitive trial.
317+
318+
Report **both** Procrustes variants (scaled = shape-only; orthogonal =
319+
rotation-only, scale-sensitive) — they are not interchangeable (§9.3).
320+
321+
### 11.5 Boundaries (what these primitives do NOT claim)
322+
323+
- **No shared latent** for EEG + language + world-state + memory. Coupled via
324+
learned cross-attention/alignment; §7 concatenation remains deferred and is the
325+
wrong fusion.
326+
- **No cross-validation between the two research programs.** The D8 sleep study
327+
does not validate the JEPA architecture, nor vice versa — orthogonal questions,
328+
no logical dependency.
329+
- **No label-free metric is an oracle.** $(\mathrm{PR},\alpha)$, $N_{\mathrm{PR}}$,
330+
RankMe can all fail (RankMe shows no correlation with some downstream tasks; all
331+
break under collapse). Anchor promotion to a downstream number — MPC success
332+
(WorldModel) or blind human novelty (D8) — never to a geometry statistic alone.

‎docs/Research.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ Inter-rater reliability: Fleiss' κ.
115115

116116
### Exploratory
117117

118-
- EEG spectral correlates of dream report content (e.g., does theta power during REM correlate with problem-relevance?).
118+
- **Aperiodic-exponent (1/f slope) correlates.** Per [`Math.md` §11.2](Math.md), the aperiodic exponent $\chi$ during N2/SWS is a literature-backed, **pre-registerable** secondary hypothesis ($\chi$ ↔ insight quality — the aperiodic slope indexes E/I balance and varies across sleep stages), not a post-hoc theta correlation. Alpha dropout is computed aperiodic-adjusted ($r_\alpha^{\mathrm{corr}}$) so a broadband 1/f shift does not masquerade as an alpha change.
119+
- **Automated novelty ($N_{\mathrm{PR}}$).** Per [`Math.md` §11.3](Math.md), report the participation-ratio novelty $N_{\mathrm{PR}}$ over the LLM-extracted analogy set as an automated companion to the blind human Likert (H1), and pre-register the Spearman $\rho$ between $N_{\mathrm{PR}}$-novelty and mean blind human novelty (reported beside H4's LLM–human agreement). $N_{\mathrm{PR}}$ catches paraphrastic near-loops that an exact-repeat count misses.
119120
- Correlation between sleep stage duration and insight quality.
120121
- LLM analysis accuracy vs. human rater agreement.
121122

@@ -153,6 +154,7 @@ Inter-rater reliability: Fleiss' κ.
153154
- The sham condition still involves wearing a headband, which may affect sleep quality differently from the no-hardware control.
154155
- Dream reports are inherently subjective and may be influenced by demand characteristics.
155156
- The LLM in the loop is a moving target; the system used at study start is not the system used at study end. Document the model version per session.
157+
- **Cross-representation (EEG ↔ language) alignment is not analyzed at pilot N.** Per [`Math.md` §11.4](Math.md), with N ≈ 20–30 matched pairs and embedding dimension in the hundreds we are in the $n \not\gg d$ regime where CKA/SVCCA are unreliable; the EEG-latent ↔ solution-embedding coupling analysis is deferred to the definitive trial, or run only after reducing each space to $k \ll n$ dimensions (SVCCA $\tau$-truncation). Both Procrustes variants (scaled, orthogonal) are reported when it is run — they are not interchangeable.
156158

157159
## Open Research Questions Beyond D8
158160

0 commit comments

Comments
 (0)