Conversation
…555) The previous implementation computed: σ_t = sqrt((1-α)*σ_{t-1}² + α*x_t²) which is the root mean square of raw values. For a series like 1..50, this returns values near the mean (~45), not the standard deviation (~5). The fix tracks the EWM mean and uses deviations from it: mean_t = (1-α)*mean_{t-1} + α*x_t var_t = (1-α)*var_{t-1} + α*(x_t - mean_{t-1})² σ_t = sqrt(var_t) ewmCovMatrix is updated consistently to subtract the EWM mean vector so that the diagonal of ewmCovMatrix still equals ewmVar (property preserved). The existing test expected value for annualVol (0.14437 → 0.14553) is updated to reflect the correct computation on stock returns with non-zero means. A regression test for issue #555 is added. Co-authored-by: Copilot <[email protected]>
9 tasks
…ation-a64d733185a9dd64
…ation-a64d733185a9dd64
…ation-a64d733185a9dd64
…ation-a64d733185a9dd64
Member
|
/repo-assist adjust this by deprecating the old function and repacing it with two functions that make the two cases clearer ewmVolStdDev and ewmVolRMS Add testing for both |
- Add ewmVolStdDev (mean-corrected standard deviation, current behaviour) - Add ewmVolRMS (root-mean-square, no mean correction) - Both overloads for Series and Frame - Mark ewmVol as [<Obsolete>] pointing to the two new functions - Update ewmVar to call ewmVolStdDev directly - Add tests for ewmVolStdDev and ewmVolRMS Co-authored-by: Copilot <[email protected]>
Contributor
Author
|
Commit pushed:
|
Contributor
Author
|
🤖 Repo Assist here — updated as requested. I've pushed the refactoring to this branch:
|
…ation-a64d733185a9dd64
Member
|
/repo-assist The behaviour of ewmVol should remain unchanged from current main, we're marking it obsolete and redirecting people to avoid a difficult breaking change for consumers Also fix all the XML docs in the file that contain |
- ewmVol (Series/Frame): restore original RiskMetrics RMS formula from main, preserving exact backward-compatible behavior for existing consumers - ewmVol: update Obsolete message to redirect to ewmVolRMS (same formula) or ewmVolStdDev (mean-corrected standard deviation) - ewmVol Frame: inline original RMS logic to avoid internal deprecation warning - Fix all [category: ...] style XML doc comments to proper <category>...</category> XML format (ewmVolRMS x2, ewmVol x2) - Rename misleading test name from 'ewmVol on non-returns...' to 'ewmVolStdDev on non-returns...' since it tests ewmVolStdDev Co-authored-by: Copilot <[email protected]>
Contributor
Author
|
Commit pushed:
|
dsyme
approved these changes
Mar 9, 2026
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Fixes
Finance.ewmVolreturning values near the series mean instead of the standard deviation — as reported in #555.Root Cause
The old formula computed the exponentially weighted root mean square of raw values:
This matches the formula used by
pandas.ewm(adjust=False).std()in structure (without the bias correction that Pandas applies by default).ewmCovMatrixis updated consistently to subtract the EWM mean vector, preserving the invariant that the diagonal ofewmCovMatrixequalsewmVar.Changes
src/Deedle.Math/Finance.fs: FixewmVolandewmCovMatrixformulastests/Deedle.Math.Tests/Finance.fs: Add regression test; update expectedannualVolfrom0.14437→0.14553(the old value was computed using the incorrect formula applied to stock returns with non-zero means)Test Status
Build: ✅ Both
DeedleandDeedle.Mathcompile successfully.Tests: The test runner requires .NET 5.0 which is not available in this environment (only .NET 8/9/10 are present — infrastructure issue). Logic was validated by running an F# script directly against the compiled DLLs:
ewmVolon1..50with span=10 → 5.50 (old formula: 45.5 = same as mean) ✅ewmVarvs diagonal ofewmCovMatrix) → diff = ~1e-19 ✅Closes #555