Align ntfperf integration grid#92
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ntf_analyzer.ntf_analyzer's historical Python grid as the default.ntfperfuse MATLABntfperf.m's grid contract by default:w = (1:N)/N/2,N = 1_000_000.ntfperfas a simple alias.Rationale
This is a grid-policy alignment, not a core algorithm change. Python and MATLAB already use the same integrated squared-magnitude formula:
The observed mismatch comes from the integration grid:
ntf_analyzerremains the lightweight Python analyzer.ntfperfis the MATLAB-compatible wrapper, so it now defaults to MATLAB's grid while still exposingn_gridfor tests and experimentation.Experiment
Dataset/function cases generated from MATLAB
ntfperf.mand Python on the same NTFs:[1,-1]/[1,0], band[0, 0.5/16]30.9616429351113+0.00135217234930.9602907627623+2.84e-14[1,-2,1]/[1,0,0], band[0, 0.5/16]47.3320195872251+0.00220836654247.3298112206832-2.84e-14[1,0,1]/[1,0,0], band[0.24, 0.26]36.7669311709645-0.00323885492136.77017002588560Tests
uv run --with pytest pytest tests/unit/oversampling/test_matlab_compat_api.py -quv run --with pytest pytest tests/unit/oversampling/test_noise_shaping_examples.py -quv run --with pytest pytest tests/unit/oversampling/test_ntf_analyzer.py -q -m "not slow"uv run --with pytest pytest tests/unit/oversampling/test_matlab_compat_api.py tests/unit/oversampling/test_noise_shaping_examples.py tests/unit/oversampling/test_ntf_analyzer.py -q -m "not slow"git diff --check