mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-22 04:28:04 +00:00
[CodeFactor] Apply fixes to commit 0606491
This commit is contained in:
@@ -381,7 +381,7 @@ public sealed class InertiaTests
|
||||
var inertia = new Inertia(period: 5);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
inertia.Update(new TValue(DateTime.UtcNow, 100.0 + i * 2.0));
|
||||
inertia.Update(new TValue(DateTime.UtcNow, 100.0 + (i * 2.0)));
|
||||
}
|
||||
// Perfect linear trend → regression fits perfectly → residual = 0
|
||||
Assert.Equal(0.0, inertia.Last.Value, precision: 10);
|
||||
|
||||
@@ -174,10 +174,10 @@ public sealed class InertiaValidationTests : IDisposable
|
||||
sumX2 += x * x;
|
||||
}
|
||||
|
||||
double denom = n * sumX2 - sumX * sumX;
|
||||
double slope = (n * sumXY - sumX * sumY) / denom;
|
||||
double intercept = (sumY - slope * sumX) / n;
|
||||
double tsf = slope * (n - 1) + intercept;
|
||||
double denom = (n * sumX2) - (sumX * sumX);
|
||||
double slope = ((n * sumXY) - (sumX * sumY)) / denom;
|
||||
double intercept = (sumY - (slope * sumX)) / n;
|
||||
double tsf = (slope * (n - 1)) + intercept;
|
||||
double expected = raw[^1] - tsf;
|
||||
|
||||
_output.WriteLine($"Manual Inertia: {expected:F12}");
|
||||
|
||||
Reference in New Issue
Block a user