feat(tests): enhance tests with GBM for noise generation and improve tolerance for MAMA validation

feat(trends): implement IDisposable in Bessel and Conv classes to manage event subscriptions
fix(trends): add validation for period and parameters in Kama and MGDI calculations
fix(trends): clamp logarithmic calculations in JMA to avoid -Infinity
This commit is contained in:
Miha Kralj
2025-12-25 20:18:14 -08:00
parent df598c810d
commit ac8b2dbb3f
20 changed files with 281 additions and 187 deletions
+22
View File
@@ -103,6 +103,18 @@ public sealed class Tema : AbstractBase
// We don't need the output, just the final state
int len = source.Length;
double lastValid = 0;
// Search for the first finite value to initialize lastValid
// If no finite value is found, lastValid remains 0
for (int i = 0; i < len; i++)
{
if (double.IsFinite(source[i]))
{
lastValid = source[i];
break;
}
}
EmaState s1 = _state1;
EmaState s2 = _state2;
EmaState s3 = _state3;
@@ -312,6 +324,16 @@ public sealed class Tema : AbstractBase
double decay = 1.0 - alpha;
double lastValid = 0;
// Search for the first finite value to initialize lastValid
for (int i = 0; i < source.Length; i++)
{
if (double.IsFinite(source[i]))
{
lastValid = source[i];
break;
}
}
// State for EMA1
double ema1_val = 0;
double ema1_e = 1.0;