pymc icon indicating copy to clipboard operation
pymc copied to clipboard

Add `drop_first` option to `HSGPPeriodic`

Open bwengals opened this issue 1 year ago • 1 comments

Description

Adds drop_first, defaults to False, in the arguments for HSGPPeriodic. Sometimes, but not always, the first sine and cosine basis vectors are all zeros and all ones respectively. Previously, we were always removing the first sine basis vector, whether it was all zeros or not. When drop_first=False, no basis vectors are dropped. When drop_first=True, both are dropped. The all-zero sine component can be safely dropped because it contributes nothing to the model. The all-one cosine component will likely cause sampling problems by adding an extra intercept to the model (which is what got me to do the PR).

If the user would like to do more specific things like keep the cosine intercept but drop the first sine component, they can fall back to prior_linearized and do their own thing.

I'm wondering if always dropping the first sine basis vector -- even though its not always all zeros, is what led to the super slight mismatches between the HSGP approx and the unapproximated GP @theorashid? Whether or not the first sine basis vector is all zeros (and so the first cosine basis vec is all ones) depends on the period that is set. I uncommented the test that was xfailed before. Still fails, so maybe its something else. Will look into this more.

TODOs

  • [ ] Test that the indexing works with an odd numbered m.
  • [ ] Verify if always dropping the sine component was causing the slight mismatch in the approx to the true.

Related Issue

  • [x] None

Checklist

Type of change

  • [x] New feature / enhancement
  • [ ] Bug fix
  • [x] Documentation
  • [ ] Maintenance
  • [ ] Other (please specify):

📚 Documentation preview 📚: https://pymc--7115.org.readthedocs.build/en/7115/

bwengals avatar Jan 23 '24 23:01 bwengals

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (627a8dd) 90.41% compared to head (c667927) 92.36%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7115      +/-   ##
==========================================
+ Coverage   90.41%   92.36%   +1.94%     
==========================================
  Files         101      101              
  Lines       16930    16937       +7     
==========================================
+ Hits        15308    15644     +336     
+ Misses       1622     1293     -329     
Files Coverage Δ
pymc/gp/hsgp_approx.py 95.80% <100.00%> (+0.18%) :arrow_up:

... and 6 files with indirect coverage changes

codecov[bot] avatar Jan 23 '24 23:01 codecov[bot]