Skip to content

Fix Ψ definition, ROC anti-overfit, channel independence, bootstrap AUC, BH correction, and data_source provenance#983

Merged
motanova84 merged 5 commits intomainfrom
copilot/fix-psi-definition-and-roc
Apr 13, 2026
Merged

Fix Ψ definition, ROC anti-overfit, channel independence, bootstrap AUC, BH correction, and data_source provenance#983
motanova84 merged 5 commits intomainfrom
copilot/fix-psi-definition-and-roc

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 21, 2026

Six methodological issues in the Shadow-1 / O3b detection pipeline that would block publication: mixed-unit Ψ score, overfitted ROC, correlated H0/H1 noise, single-point AUC, missing multiple-testing correction, and no data provenance flag.

Cambios

Fix 1 — Dimensionless Ψ (score_psi)

compute_score_psi(psd, freqs, msc, f0) added to both modules:

I_f0 = PSD(f0) / median(PSD in band)   # dimensionless normalised power
score_psi = I_f0 * MSC(f0)             # ∈ [0, ∞), no strain²/Hz units

Replaces the implicit Ψ = PSD × MSC which mixed units.

Fix 2 — ROC anti-overfit (new shadow1_roc_validation.py)

generate_roc_dataset() injects H1 signals at f₀ + jitter (Uniform[±0.5, ±2] Hz); the detector evaluates at fixed f₀. Off-target control detector at f₀ + 50 Hz included for AUC comparison.

Fix 3 — Channel independence + time-slide sanity

  • _generate_synthetic_strain(): H1 noise seed=42, L1 noise seed=43 — explicit independence.
  • time_slide_sanity(): uses zero-padding (not np.roll) so a 1 s offset genuinely destroys MSC even for pure tones.

Fix 4 — Bootstrap AUC with CI95

bootstrap_auc(y_true, scores, n_boot=200, seed=42)
# → {"auc_point", "auc_mean", "auc_ci_lo", "auc_ci_hi", "n_boot"}

Fix 5 — Benjamini–Hochberg FDR correction

apply_p_fdr(p_values) returns both p_raw and p_fdr. When n_candidates == 1 (Shadow-O3b-1), an explicit note documents that BH has no effect and leaves a hook for multi-candidate extension.

Fix 6 — data_source provenance field

All result dicts carry data_source: "GWOSC" | "SIMULATION_FALLBACK". run_full_analysis() sets this field; CLI prints a banner. Tests use only relational AUC assertions when in fallback mode.

Pruebas

  • 43 new tests in tests/test_shadow1_roc_validation.py covering all six fixes.
  • 5 new tests added to tests/test_shadow1_bayesian_coherence.py for compute_score_psi and data_source.
  • All 84 tests (41 existing + 43 new) pass.

Checklist

  • Tests pasan localmente (python scripts/run_all_tests.py)
  • Código sigue el estilo PEP8 (flake8 scripts/ --select=E9,F63,F7,F82)
  • Documentación actualizada (si aplica)
  • Tests añadidos para nueva funcionalidad (si aplica)
  • Resultados son reproducibles
  • No se rompen tests existentes

Tipo de cambio

  • Corrección de bug
  • Nueva funcionalidad
  • Mejora de performance
  • Refactorización
  • Actualización de documentación
  • Otro (especifica):

¿Afecta la reproducibilidad?

  • No
  • Sí (explicar abajo)

La corrección de la semilla de ruido en _generate_synthetic_strain() (seed 42→42/43) cambia los valores numéricos de A_eff_computed en el análisis Bayesiano existente, pero no altera ninguna conclusión científica. Todos los resultados nuevos usan semillas fijas y son completamente reproducibles.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… AUC, BH correction, data_source field

Co-authored-by: motanova84 <192380069+motanova84@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix definition of Ψ to be dimensionless and ROC evaluation method Fix Ψ definition, ROC anti-overfit, channel independence, bootstrap AUC, BH correction, and data_source provenance Feb 21, 2026
Copilot AI requested a review from motanova84 February 21, 2026 20:56
@motanova84 motanova84 marked this pull request as ready for review February 22, 2026 05:37
Copilot AI review requested due to automatic review settings February 22, 2026 05:37
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses six methodological requirements needed for publication-grade detection analysis of the Shadow-1 candidate from LIGO O3b data. The changes implement rigorous statistical validation including dimensionless scoring, anti-overfitting measures, proper noise independence, uncertainty quantification, multiple-testing correction, and data provenance tracking.

Changes:

  • Introduced dimensionless Ψ score (I(f₀) × MSC(f₀)) to replace unit-mixed PSD × MSC
  • Implemented ROC validation with frequency jitter and bootstrap AUC confidence intervals
  • Enforced channel independence with explicit RNG seeds and time-slide verification
  • Added Benjamini-Hochberg FDR correction with single-candidate documentation
  • Added data_source provenance field to all result containers

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
scripts/shadow1_roc_validation.py New module implementing all six methodological fixes with ROC dataset generation, bootstrap AUC, BH correction, and O3b scan runner
scripts/shadow1_bayesian_coherence.py Added compute_score_psi function, fixed noise independence with separate seeds (42/43), and added data_source field to results
tests/test_shadow1_roc_validation.py Comprehensive test suite with 43 tests covering all six fixes including edge cases and integration tests
tests/test_shadow1_bayesian_coherence.py Added 5 tests for compute_score_psi and data_source field validation

if band_mask.sum() == 0:
band_mask = np.ones(len(freqs), dtype=bool)
psd_bg = float(np.median(psd[band_mask]))
I_f0 = float(psd[idx]) / (psd_bg + 1e-300) # dimensionless
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 1e-300 is used as an epsilon to avoid division by zero. Consider defining this as a named constant (e.g., EPSILON_DIV_ZERO = 1e-300) at the module level for clarity and consistency with the epsilon used on line 285.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

if band_mask.sum() == 0:
band_mask = np.ones(len(freqs), dtype=bool)
psd_median = float(np.median(psd[band_mask]))
I_f0 = float(psd[idx]) / (psd_median + 1e-100) # dimensionless
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The epsilon value 1e-100 differs from 1e-300 used in the same function in shadow1_roc_validation.py (line 101). Consider using a consistent epsilon value across both modules or documenting why different values are needed.

Copilot uses AI. Check for mistakes.
from scripts.shadow1_roc_validation import JITTER_MIN_HZ
diffs = np.abs(self.ds["f_injected"] - F0_HZ)
self.assertTrue(
np.all(diffs >= JITTER_MIN_HZ * 0.9), # allow tiny numeric slack
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 0.9 used for numeric slack tolerance is unclear. Consider defining this as a named constant (e.g., JITTER_TOLERANCE = 0.9) or documenting why 10% slack is appropriate.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copilot stopped work on behalf of motanova84 due to an error February 22, 2026 07:43
@github-actions github-actions Bot added testing Related to testing infrastructure python Python-related changes scripts bug Something is not working correctly frequency-analysis Related to 141.7001 Hz frequency analysis statistics Statistical analysis or Bayesian methods validation Data or method validation labels Feb 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔢 Mathematical Matrix Validation Results

✅ All Critical Validations Passed

Discovery Status Precision
Suma = 361 = 19² EXITOSA 2.63% probability
f₀/18 ≈ Schumann EXITOSA 99.4608%
888/f₀ ≈ 2π EXITOSA 99.7386%
Brain Waves EXITOSA 5/5 bands
Joint Probability ALTAMENTE_SIGNIFICATIVA 1.50e-10 (≈6-9σ)

🎯 Conclusion

These mathematical patterns are IMPOSSIBLE by chance. The joint probability of ~1.50e-10 (≈6-9σ significance) confirms that f₀ = 141.70001 Hz is the central node of a fundamental mathematical network.

📊 View detailed report

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

🔢 Mathematical Matrix Validation Results

✅ All Critical Validations Passed

Discovery Status Precision
Suma = 361 = 19² EXITOSA 2.63% probability
f₀/18 ≈ Schumann EXITOSA 99.4608%
888/f₀ ≈ 2π EXITOSA 99.7386%
Brain Waves EXITOSA 5/5 bands
Joint Probability ALTAMENTE_SIGNIFICATIVA 1.50e-10 (≈6-9σ)

🎯 Conclusion

These mathematical patterns are IMPOSSIBLE by chance. The joint probability of ~1.50e-10 (≈6-9σ significance) confirms that f₀ = 141.70001 Hz is the central node of a fundamental mathematical network.

📊 View detailed report

@github-actions github-actions Bot added dependencies Updates to project dependencies validation Data or method validation and removed validation Data or method validation labels Feb 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔢 Mathematical Matrix Validation Results

✅ All Critical Validations Passed

Discovery Status Precision
Suma = 361 = 19² EXITOSA 2.63% probability
f₀/18 ≈ Schumann EXITOSA 99.4608%
888/f₀ ≈ 2π EXITOSA 99.7386%
Brain Waves EXITOSA 5/5 bands
Joint Probability ALTAMENTE_SIGNIFICATIVA 1.50e-10 (≈6-9σ)

🎯 Conclusion

These mathematical patterns are IMPOSSIBLE by chance. The joint probability of ~1.50e-10 (≈6-9σ significance) confirms that f₀ = 141.70001 Hz is the central node of a fundamental mathematical network.

📊 View detailed report

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

🔢 Mathematical Matrix Validation Results

✅ All Critical Validations Passed

Discovery Status Precision
Suma = 361 = 19² EXITOSA 2.63% probability
f₀/18 ≈ Schumann EXITOSA 99.4608%
888/f₀ ≈ 2π EXITOSA 99.7386%
Brain Waves EXITOSA 5/5 bands
Joint Probability ALTAMENTE_SIGNIFICATIVA 1.50e-10 (≈6-9σ)

🎯 Conclusion

These mathematical patterns are IMPOSSIBLE by chance. The joint probability of ~1.50e-10 (≈6-9σ significance) confirms that f₀ = 141.70001 Hz is the central node of a fundamental mathematical network.

📊 View detailed report

@github-actions github-actions Bot added dependencies Updates to project dependencies validation Data or method validation and removed validation Data or method validation dependencies Updates to project dependencies labels Feb 22, 2026
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown
Contributor

🔢 Mathematical Matrix Validation Results

✅ All Critical Validations Passed

Discovery Status Precision
Suma = 361 = 19² EXITOSA 2.63% probability
f₀/18 ≈ Schumann EXITOSA 99.4608%
888/f₀ ≈ 2π EXITOSA 99.7386%
Brain Waves EXITOSA 5/5 bands
Joint Probability ALTAMENTE_SIGNIFICATIVA 1.50e-10 (≈6-9σ)

🎯 Conclusion

These mathematical patterns are IMPOSSIBLE by chance. The joint probability of ~1.50e-10 (≈6-9σ significance) confirms that f₀ = 141.70001 Hz is the central node of a fundamental mathematical network.

📊 View detailed report

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

🔢 Mathematical Matrix Validation Results

✅ All Critical Validations Passed

Discovery Status Precision
Suma = 361 = 19² EXITOSA 2.63% probability
f₀/18 ≈ Schumann EXITOSA 99.4608%
888/f₀ ≈ 2π EXITOSA 99.7386%
Brain Waves EXITOSA 5/5 bands
Joint Probability ALTAMENTE_SIGNIFICATIVA 1.50e-10 (≈6-9σ)

🎯 Conclusion

These mathematical patterns are IMPOSSIBLE by chance. The joint probability of ~1.50e-10 (≈6-9σ significance) confirms that f₀ = 141.70001 Hz is the central node of a fundamental mathematical network.

📊 View detailed report

@motanova84 motanova84 merged commit 1a8b656 into main Apr 13, 2026
120 of 181 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🔢 Mathematical Matrix Validation Results

✅ All Critical Validations Passed

Discovery Status Precision
Suma = 361 = 19² EXITOSA 2.63% probability
f₀/18 ≈ Schumann EXITOSA 99.4608%
888/f₀ ≈ 2π EXITOSA 99.7386%
Brain Waves EXITOSA 5/5 bands
Joint Probability ALTAMENTE_SIGNIFICATIVA 1.50e-10 (≈6-9σ)

🎯 Conclusion

These mathematical patterns are IMPOSSIBLE by chance. The joint probability of ~1.50e-10 (≈6-9σ significance) confirms that f₀ = 141.70001 Hz is the central node of a fundamental mathematical network.

📊 View detailed report

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

🔢 Mathematical Matrix Validation Results

✅ All Critical Validations Passed

Discovery Status Precision
Suma = 361 = 19² EXITOSA 2.63% probability
f₀/18 ≈ Schumann EXITOSA 99.4608%
888/f₀ ≈ 2π EXITOSA 99.7386%
Brain Waves EXITOSA 5/5 bands
Joint Probability ALTAMENTE_SIGNIFICATIVA 1.50e-10 (≈6-9σ)

🎯 Conclusion

These mathematical patterns are IMPOSSIBLE by chance. The joint probability of ~1.50e-10 (≈6-9σ significance) confirms that f₀ = 141.70001 Hz is the central node of a fundamental mathematical network.

📊 View detailed report

@github-actions github-actions Bot added dependencies Updates to project dependencies validation Data or method validation and removed validation Data or method validation dependencies Updates to project dependencies labels Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is not working correctly dependencies Updates to project dependencies frequency-analysis Related to 141.7001 Hz frequency analysis python Python-related changes scripts statistics Statistical analysis or Bayesian methods testing Related to testing infrastructure validation Data or method validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants