Skip to content

Commit a3c6133

Browse files
committed
Merge branch 'dev'
2 parents dbe9f81 + f582db2 commit a3c6133

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/averages/Mama.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private static double CalculateHilbertTransform(CircularBuffer buffer, double ad
111111
[MethodImpl(MethodImplOptions.AggressiveInlining)]
112112
private double CalculatePeriod(double im, double re)
113113
{
114-
if (im == 0 || re == 0) return _pd[^2];
114+
if (System.Math.Abs(im) <= double.Epsilon || System.Math.Abs(re) <= double.Epsilon) return _pd[^2];
115115
return _twoPi / System.Math.Atan(im / re);
116116
}
117117

@@ -167,7 +167,7 @@ protected override double Calculation()
167167
_pd[^1] = AdjustPeriod(_pd[^1]);
168168

169169
// Phase calculation
170-
double phase = _i1[^1] != 0 ? System.Math.Atan(_q1[^1] / _i1[^1]) * _radToDeg : _ph[^2];
170+
double phase = Math.Abs(_i1[^1]) >= double.Epsilon ? System.Math.Atan(_q1[^1] / _i1[^1]) * _radToDeg : _ph[^2];
171171
_ph.Add(phase, Input.IsNew);
172172

173173
// Adaptive alpha

lib/errors/Mase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private double CalculateMase()
120120
double sumAbsoluteError = CalculateSumAbsoluteError(actualValues, predictedValues);
121121
double naiveForecastError = CalculateNaiveForecastError(actualValues, naiveValues);
122122

123-
return naiveForecastError != 0 ? (sumAbsoluteError / _actualBuffer.Count) / naiveForecastError : double.PositiveInfinity;
123+
return naiveForecastError >= double.Epsilon ? (sumAbsoluteError / _actualBuffer.Count) / naiveForecastError : double.PositiveInfinity;
124124
}
125125

126126
/// <summary>

0 commit comments

Comments
 (0)