Skip to content

Interpret GaussianSmoothingSettings.sigma in seconds; warn on identity kernel - #169

Merged
cboulay merged 1 commit into
devfrom
fix-167-gaussian-sigma-units
Jul 8, 2026
Merged

Interpret GaussianSmoothingSettings.sigma in seconds; warn on identity kernel#169
cboulay merged 1 commit into
devfrom
fix-167-gaussian-sigma-units

Conversation

@cboulay

@cboulay cboulay commented Jul 8, 2026

Copy link
Copy Markdown
Member

Fixes #167.

Problem

GaussianSmoothingSettings.sigma was silently used as a sample count: the design wrapper ignored fs, so the same settings produced different smoothing bandwidths at different sampling rates, and any sigma < 1/(2*width) samples silently designed a single-tap identity kernel (which is what the existing tests at sigma=0.01 were unknowingly exercising).

Changes

  • settings.sigma is now in seconds, converted to samples using the sampling rate of the first message.
  • New default 0.01 s ≈ a 13.2 Hz low-pass at -3 dB (fc = sqrt(ln 2) / (2π·sigma), documented in the docstring). The old default of 1.0 would design enormous kernels at typical sampling rates once interpreted as seconds.
  • The standalone gaussian_smoothing_filter_design keeps sample units (it has no fs); its docstring now says so.
  • Warns when the computed kernel is single-tap (identity — no smoothing).
  • Tests updated to seconds-equivalents; new tests assert the kernel length scales with fs and that an identity kernel warns and passes data through.

Breaking change

Pipelines that passed sigma as a sample count must divide by fs.

Verified numerically: at fs=1000 the designed kernel's -3 dB point is 13.24 Hz (81 taps); at fs=50 (typical feature rate) it is a 5-tap kernel with corner ~15.5 Hz due to truncation.

…y kernel

Fixes #167. sigma was silently used as a sample count: the design wrapper
ignored fs, so the smoothing bandwidth changed with sampling rate, and any
sigma < 1/(2*width) samples degenerated to a single-tap identity kernel with
no warning. settings.sigma is now converted to samples using the sampling
rate of the first message; the standalone design function keeps sample units
(it has no fs) and warns when the computed kernel is single-tap.

The default changes from 1.0 to 0.01 s, i.e. a ~13.2 Hz low-pass at -3 dB
(fc = sqrt(ln 2) / (2*pi*sigma)) -- a sane smoothing default, where 1.0 s
would design enormous kernels at typical sampling rates.

BREAKING: pipelines that passed sigma as a sample count must divide by fs.
@cboulay
cboulay merged commit 6acff24 into dev Jul 8, 2026
14 checks passed
@cboulay
cboulay deleted the fix-167-gaussian-sigma-units branch July 8, 2026 05:40
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.

GaussianSmoothingSettings.sigma is interpreted in samples, not seconds; sub-sample sigma silently designs an identity kernel

1 participant