Skip to content

FIX: correct off-by-one in Higuchi FD inner loop#47

Merged
raphaelvallat merged 1 commit intomasterfrom
fix_higuchi
Mar 6, 2026
Merged

FIX: correct off-by-one in Higuchi FD inner loop#47
raphaelvallat merged 1 commit intomasterfrom
fix_higuchi

Conversation

@raphaelvallat
Copy link
Copy Markdown
Owner

The inner loop summed j = 1 … N_m-1 (n_max-1 terms) instead of the correct j = 1 … N_m (n_max terms), dropping the last difference in each sub-series and slightly underestimating curve length.

Fix: range(1, n_max)range(1, n_max + 1)

Also corrects the docstring formula (upper limit N_m-1N_m) and updates all higuchi_fd docstring examples and the unit test expected value to match the corrected output.

The inner loop summed j = 1 … N_m-1 (n_max-1 terms) instead of the
correct j = 1 … N_m (n_max terms), dropping the last difference in
each sub-series and slightly underestimating curve length.

Fix: range(1, n_max) → range(1, n_max + 1)

Also corrects the docstring formula (upper limit N_m-1 → N_m) and
updates all higuchi_fd docstring examples and the unit test expected
value to match the corrected output.

Verified against the NeuroKit2 reference implementation which uses
np.diff over all n_max differences.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@raphaelvallat raphaelvallat merged commit e6581bb into master Mar 6, 2026
18 checks passed
@raphaelvallat raphaelvallat deleted the fix_higuchi branch March 6, 2026 16:08
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7150019) to head (c068240).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #47   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          312       312           
  Branches        52        52           
=========================================
  Hits           312       312           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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