Skip to content

Commit

Permalink
chore: /s/windowSize/movingAvgWindowSize/g
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Sep 17, 2024
1 parent 39b134a commit f5e54cc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ee/query-service/anomaly/seasonal.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,19 @@ func (p *BaseSeasonalProvider) getStdDev(series *v3.Series) float64 {

// getMovingAvg gets the moving average for the given series
// for the given window size and start index
func (p *BaseSeasonalProvider) getMovingAvg(series *v3.Series, windowSize, startIdx int) float64 {
func (p *BaseSeasonalProvider) getMovingAvg(series *v3.Series, movingAvgWindowSize, startIdx int) float64 {
if series == nil || len(series.Points) == 0 {
return 0
}
if startIdx >= len(series.Points)-windowSize {
startIdx = len(series.Points) - windowSize
if startIdx >= len(series.Points)-movingAvgWindowSize {
startIdx = len(series.Points) - movingAvgWindowSize
}
var sum float64
points := series.Points[startIdx:]
for i := 0; i < windowSize && i < len(points); i++ {
for i := 0; i < movingAvgWindowSize && i < len(points); i++ {
sum += points[i].Value
}
avg := sum / float64(windowSize)
avg := sum / float64(movingAvgWindowSize)
return avg
}

Expand Down

0 comments on commit f5e54cc

Please sign in to comment.