Skip to content

Preserve correlation for nonconstant small-angle samples - #24

Open
antonsoo wants to merge 1 commit into
circstat:mainfrom
antonsoo:fix/small-angle-correlation
Open

antonsoo wants to merge 1 commit into
circstat:mainfrom
antonsoo:fix/small-angle-correlation

Conversation

@antonsoo

Copy link
Copy Markdown

Valid small-angle samples are rejected as degenerate because the Fisher–Lee and Jammalamadaka–SenGupta implementations compare positive variance terms with an absolute np.isclose(..., 0) tolerance. For example:

import numpy as np
from pycircstat2.correlation import circ_corrcc

a = 1e-5 * np.array([0., 1., 4., 2., 3.])
print(circ_corrcc(a, a, method="fl"))
print(circ_corrcc(a, a, method="js", test=True))

Both currently raise despite nonconstant input and unit self-correlation. Accept positive representable denominator and fourth-moment values. Keep constant and antipodal inputs degenerate by checking raw-angle sine residuals against argument-scale rounding, rather than imposing a fixed variance floor.

The new regressions cover small nonconstant samples, both inference modes, nonzero constants, antipodal directions and full-turn aliases. Nine configurations fail on unchanged main; all 28 pass afterward. The full suite passes 394 tests with hea==0.1.2; the fatal Flake8 gate passes. The existing latest-Hea collection limitation noted in #23 is unchanged.

A separate workload uses unmodified recorded KITTI OXTS roll/pitch/yaw windows. All 168 public calls that previously failed now agree with independent scalar pair sums/rescaled-moment references within 7.4e-11. Nine ordinary bundled-data controls remain exact. These checks establish numerical evaluation, not calibration of inference on serial sensor data. #21's current head still reproduces the failures. This is separate from #23's jackknife standard-error correction; extremely small products can still underflow.

@huangziwei

Copy link
Copy Markdown
Collaborator

will go through your patches next week. I'd like to upgrade hea with polars 2.0 first and cleared all upstream compatibility first. thanks for the help.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants