-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Bug summary
HSGPPeriodic appears to apply periodic basis coefficients at the wrong scale, which can distort the GP prior variance and produce systematically incorrect prior draws.
This is not a cosmetic mismatch: it can change model behavior and inference quality whenever users rely on HSGPPeriodic as an approximation to gp.Latent with a periodic kernel.
Why this is high impact
- It affects prior correctness for a core GP approximation API.
- It can bias uncertainty and function amplitudes before seeing any data.
- It directly undermines the expected equivalence between
HSGPPeriodicand full periodic GP priors.
Evidence in code
1) Coefficients are documented/returned as variance-level terms (q_j^2)
pymc/gp/cov.py(Periodic.power_spectral_density_approx): docs and implementation indicate coefficients correspond to (\tilde q_j^2).
2) Same coefficients are used as if they were std-level terms
pymc/gp/hsgp_approx.py(HSGPPeriodic.prior_linearized,prior,_build_conditional): coefficients are multiplied directly intobeta ~ Normal(0,1)via terms likephi @ (coeff * beta).
If coeff = q_j^2, then variance contribution becomes (q_j^2)^2 instead of q_j^2.
Observable symptom
The periodic prior equivalence test is currently xfailed:
tests/gp/test_hsgp_approx.py::TestHSGPPeriodic::test_prior
A scaling mismatch is a plausible root cause of this persistent mismatch.
Expected behavior
When beta ~ Normal(0,1), basis multipliers should be std-level coefficients.
If the covariance helper returns variance-level coefficients (q_j^2), HSGPPeriodic should use sqrt(q_j^2) at the multiplication site.
Suggested fix direction
- Option A (minimal): keep
power_spectral_density_approxas variance-level output and applypt.sqrt(...)inHSGPPeriodicwhere coefficients multiplybeta. - Option B: change semantics/API so the helper returns std-level coefficients consistently, then update naming/docs accordingly.
Either way, resolving this should help un-xfail periodic prior equivalence and restore expected approximation behavior.