From c24e70fd98bb61ddf735a7f54e278258f2dfc990 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Wed, 15 Dec 2021 23:44:19 -0500 Subject: More general work. --- ma/ma.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'ma') diff --git a/ma/ma.go b/ma/ma.go index 5c3558b..b591d19 100644 --- a/ma/ma.go +++ b/ma/ma.go @@ -1,8 +1,6 @@ package ma import ( - "math" - "github.com/hawkinsw/goresponsiveness/saturating" "github.com/hawkinsw/goresponsiveness/utilities" ) @@ -34,13 +32,13 @@ func (ma *MovingAverage) CalculateAverage() float64 { return float64(total) / float64(ma.divisor.Value()) } -func (ma *MovingAverage) ConsistentWithin(limit float64) bool { +func (ma *MovingAverage) IncreasesLessThan(limit float64) bool { previous := ma.instants[0] for i := 1; i < ma.intervals; i++ { current := ma.instants[i] - percentChange := utilities.AbsPercentDifference(current, previous) + percentChange := utilities.SignedPercentDifference(current, previous) previous = current - if math.Abs(percentChange) > limit { + if percentChange > limit { return false } } -- cgit v1.2.3