Repository navigation
Welch estimation pooled over multiple data segments in tfest and coherence - #211
Open
baggepinnen wants to merge 1 commit into
Open
baggepinnen wants to merge 1 commit into
baggepinnen wants to merge 1 commit into
Conversation
tfest and coherence accept a vector of iddata segments of possibly different lengths. The cross- and auto-spectral sums are accumulated over the Welch windows of all segments, each window lying within a single segment, before the transfer function, noise spectrum and coherence are formed. wcfft accepts vectors of signal segments for this purpose. Assisted-by: Claude-Code:claude-opus-5-5
This branch has not been deployed
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
tfest(d; method = :welch)andcoherence(d)returnH, the noise spectrum and κ², but not the Welch sums. Pooling Welch estimates over several data segments (for example repeated experiments, or disjoint parts of one experiment in which every window must lie within one part) therefore required recovering the sums algebraically from the returned quantities or calling the internalwcfft.This PR adds Welch estimation pooled over a vector of data segments of possibly different lengths:
tfest(ds::AbstractVector{<:AbstractIdData}; n = minimum(length, ds) ÷ 10, noverlap = n ÷ 2, window = hamming)returnsH, N.coherence(ds::AbstractVector{<:AbstractIdData}; n, noverlap, window)returns κ².wcfft(ys::AbstractVector{<:AbstractVector}, us::AbstractVector{<:AbstractVector}; n, noverlap, window)accumulates the cross- and auto-spectral sums over the windows of all segments; the existingwcfft(y, u)forwards to it.The sums are accumulated over all windows of all segments before
H,Nand κ² are formed, so the result equals the Welch estimate over the union of the windows, not an average of per-segment estimates. Every window lies within one segment; a segment shorter thanncontributes no window.Nis normalized by the total number of samples of the contributing segments. Onlymethod = :welchis supported for vectors (other methods throw anArgumentError); multiple outputs are handled output by output intfest, as for a single dataset. The API follows the existing vector-of-datasets methodsarx(ds::AbstractVector{<:AbstractIdData}, ...)andera(ds::AbstractVector{<:AbstractIdData}, ...). As a consequence,tfest(ds, G0::LTISystem)now also accepts a vector of segments.Tests (test/test_frd.jl)
tfest(d; method = :welch)andcoherence(d), with explicit and default window lengths.wcfftsums.test/test_frd.jlpasses locally (76 tests).Documentation
Docstrings for the new methods and for
wcfft, cross-references from the single-dataset docstrings, and a subsection "Multiple data segments" indocs/src/freq.md.Host: battomenstation, session ceeed800-f3a6-49ab-a067-a9619908b6cb, working directory /tmp/claude-1000/-home-fredrikb-repos-QBotControl-Qbot/ceeed800-f3a6-49ab-a067-a9619908b6cb/scratchpad/CSI
🤖 Generated with Claude Code
https://claude.ai/code/session_01JGy8YaVQubQ5iZpmGTGTfG