summaryrefslogtreecommitdiff
path: root/ma/ma.go
diff options
context:
space:
mode:
Diffstat (limited to 'ma/ma.go')
-rw-r--r--ma/ma.go5
1 files changed, 2 insertions, 3 deletions
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