diff options
| author | Will Hawkins <[email protected]> | 2021-12-15 23:44:19 -0500 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2021-12-15 23:44:19 -0500 |
| commit | c24e70fd98bb61ddf735a7f54e278258f2dfc990 (patch) | |
| tree | dfa9ffba2f46ec7269d77915f7c1cd1739c81e9f /ma/ma.go | |
| parent | b74e4d4261d8618ef5f99118d2b784cde2614ca2 (diff) | |
More general work.
Diffstat (limited to 'ma/ma.go')
| -rw-r--r-- | ma/ma.go | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -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 } } |
