Files
lamlvh cee2ff0859 P2 diagnosis on dev, P3 dev experiments, lock protocol_p3
- P2: SMC tie posterior (numpy + torch), RML/soft-DTW losses, bank training,
  D2 synthetic generator, scripts 09-13, protocol_p2 (locked) and its outcome
  (G-B failed; H1 not rejected, H3 rejected, H4 not rejected).
- Diagnosis on dev realizations 900/901 only (scripts 14-17, run_p3_dev.sh):
  posterior screen, SMC stability (P = 1024, K = 1), sigma_a misspecification
  stress and training, H3 with the SMC posterior, F3 placement on sigma_post.
- protocol_p3: H2 split into H2a (posterior-mean labels vs point ties) and
  H2b (RML vs posterior mean as a function of sigma_post); H3 descriptive only;
  sigma_a arm; new D2 config d2_synth_p3.yaml; main grid on realizations 8-15.
  Locked by configs/protocol_p3.sha256 and tag protocol-p3.
- runlog: per-run logs and runtime index (logs/index.csv).
- Docs: plan §12 items 10-11, theory, technical overview, report; wording
  aligned with Gunning & Glinsky (2006): the tie posterior is not claimed as new.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 06:03:33 +00:00

37 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Labels per warp sample (plan §4.3): y^(s)(t_i) = (𝒜φ)(τ^(s)(t_i)).
Logs live on the uniform fine τ grid (sonic time). 𝒜 is a zero-phase low-pass filter applied before 4 ms
sampling (as in resample.log_to_time); τ^(s) is the inverse map of t(·; u^(s)), which exists because t is
monotone.
"""
from __future__ import annotations
import numpy as np
from scipy import signal
def antialias(y: np.ndarray, d_fine_ms: float, out_dt_ms: float = 4.0, cutoff_frac: float = 0.8,
order: int = 6) -> np.ndarray:
"""Low-pass filter at cutoff_frac·Nyquist of the out_dt_ms grid (default 100 Hz for 4 ms)."""
fc = cutoff_frac * 500.0 / out_dt_ms
sos = signal.butter(order, fc, fs=1000.0 / d_fine_ms, output="sos")
return signal.sosfiltfilt(sos, y, padtype="even")
def invert_warps(t_of_tau: np.ndarray, tau: np.ndarray, t_out: np.ndarray) -> np.ndarray:
"""τ(t_out) for each warp sample; t_of_tau (S, n) strictly increasing on the tau grid. NaN outside the
domain."""
t_of_tau = np.atleast_2d(t_of_tau)
out = np.empty((len(t_of_tau), len(t_out)))
for s, ts in enumerate(t_of_tau):
out[s] = np.interp(t_out, ts, tau, left=np.nan, right=np.nan)
return out
def labels_for_warps(tau_fine: np.ndarray, y_filtered: np.ndarray, t_of_tau_fine: np.ndarray,
t_out: np.ndarray) -> np.ndarray:
"""(S, L): labels at t_out for each warp. y_filtered is the log after `antialias` on tau_fine."""
tau_at = invert_warps(t_of_tau_fine, tau_fine, t_out)
return np.where(np.isfinite(tau_at), np.interp(np.nan_to_num(tau_at), tau_fine, y_filtered), np.nan)