mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 05:48:06 +00:00
Refactor error handling and calculations in TheilU, Wmape, and TukeyBiweight classes; update buffer handling for consistency
- Updated buffer handling in TheilU and Wmape classes to ensure consistency after adding new values. - Changed the resync interval constant in TukeyBiweight for better clarity. - Refactored state structures to record structs in Gauss, Hann, Hp, Hpf, Kalman, Loess, Notch, and other filter classes for improved performance and readability. - Enhanced numerical stability in Mama class calculations using Fused Multiply-Add (FMA) for precision. - Added comprehensive tests for Atan2 validation to compare .NET's Math.Atan2 with PineScript's implementation, ensuring accuracy across various edge cases. - Updated NDepend badges to reflect changes in classes, methods, and lines of code.
This commit is contained in:
@@ -104,18 +104,15 @@ public sealed class Mase : AbstractBase
|
||||
{
|
||||
_state = _p_state;
|
||||
|
||||
// Incremental update for error buffer: get current newest, compute delta
|
||||
double currentNewestError = _errorBuffer.Count > 0 ? _errorBuffer.Newest : 0.0;
|
||||
double deltaError = absError - currentNewestError;
|
||||
_state.ErrorSum += deltaError;
|
||||
// Bar correction: update buffer and recalculate sums
|
||||
// Note: _p_state was saved BEFORE the Add, but buffer still has the added value
|
||||
// So we update newest and recalculate to ensure consistency
|
||||
_errorBuffer.UpdateNewest(absError);
|
||||
|
||||
// Incremental update for scale buffer: get current newest, compute delta
|
||||
double currentNewestScale = _scaleBuffer.Count > 0 ? _scaleBuffer.Newest : 0.0;
|
||||
double deltaScale = naiveDiff - currentNewestScale;
|
||||
_state.ScaleSum += deltaScale;
|
||||
_scaleBuffer.UpdateNewest(naiveDiff);
|
||||
|
||||
_state.ErrorSum = _errorBuffer.RecalculateSum();
|
||||
_state.ScaleSum = _scaleBuffer.RecalculateSum();
|
||||
|
||||
_state.PrevActual = actualVal;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user