Skip to content

BUG: Possible coefficient scaling mismatch in HSGPPeriodic prior (q_j^2 used as std) #8167

@SanketMeghale

Description

@SanketMeghale

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 HSGPPeriodic and 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 into beta ~ Normal(0,1) via terms like phi @ (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_approx as variance-level output and apply pt.sqrt(...) in HSGPPeriodic where coefficients multiply beta.
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions