From 728a81b8205678abeeb54a69e9e26ee06c18b607 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Tue, 14 Dec 2021 00:55:29 -0500 Subject: Refactoring -- more. --- ma/ma.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'ma/ma.go') diff --git a/ma/ma.go b/ma/ma.go index 0dee17f..5c3558b 100644 --- a/ma/ma.go +++ b/ma/ma.go @@ -4,6 +4,7 @@ import ( "math" "github.com/hawkinsw/goresponsiveness/saturating" + "github.com/hawkinsw/goresponsiveness/utilities" ) // Convert this to a Type Parameterized interface when they are available @@ -37,9 +38,7 @@ func (ma *MovingAverage) ConsistentWithin(limit float64) bool { previous := ma.instants[0] for i := 1; i < ma.intervals; i++ { current := ma.instants[i] - delta := math.Abs(current - previous) - percentChange := (float64(delta) / (float64(current+previous) / 2.0)) * float64(100) - + percentChange := utilities.AbsPercentDifference(current, previous) previous = current if math.Abs(percentChange) > limit { return false -- cgit v1.2.3