mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-22 20:48:04 +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:
@@ -107,9 +107,7 @@ public sealed class Rae : AbstractBase
|
||||
{
|
||||
_state = _p_state;
|
||||
|
||||
// Update actual buffer
|
||||
double removedActual = _actualBuffer.Count == _actualBuffer.Capacity ? _actualBuffer.Oldest : 0.0;
|
||||
_state.ActualSum = _state.ActualSum - removedActual + actualVal;
|
||||
// Update buffers and recalculate sums (buffer state is inconsistent with _p_state)
|
||||
_actualBuffer.UpdateNewest(actualVal);
|
||||
_state.ActualSum = _actualBuffer.RecalculateSum();
|
||||
|
||||
@@ -118,12 +116,9 @@ public sealed class Rae : AbstractBase
|
||||
double absError = Math.Abs(actualVal - predictedVal);
|
||||
double absBaseline = Math.Abs(actualVal - mean);
|
||||
|
||||
// Update error buffer
|
||||
_absErrorBuffer.UpdateNewest(absError);
|
||||
_state.AbsErrorSum = _absErrorBuffer.RecalculateSum();
|
||||
|
||||
// Update baseline buffer
|
||||
_absBaselineBuffer.UpdateNewest(absBaseline);
|
||||
_state.AbsErrorSum = _absErrorBuffer.RecalculateSum();
|
||||
_state.AbsBaselineSum = _absBaselineBuffer.RecalculateSum();
|
||||
}
|
||||
|
||||
@@ -292,4 +287,4 @@ public sealed class Rae : AbstractBase
|
||||
}
|
||||
}
|
||||
}
|
||||
}␍
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user