mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
promql: Improve Kahan usage in avg_over_time
The calculation of the mean value in avg_over_time is performed in an incremental fashion. This introduces additional numerical errors that even Kahan summation cannot compensate, but at least we can use the Kahan-corrected mean value when we use the intermediate mean value in the calculation. Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
c46074f4dd
commit
3a908d8e08
|
@ -593,7 +593,8 @@ func funcAvgOverTime(vals []parser.Value, args parser.Expressions, enh *EvalNode
|
|||
continue
|
||||
}
|
||||
}
|
||||
mean, c = kahanSumInc(f.F/count-mean/count, mean, c)
|
||||
correctedMean := mean + c
|
||||
mean, c = kahanSumInc(f.F/count-correctedMean/count, mean, c)
|
||||
}
|
||||
|
||||
if math.IsInf(mean, 0) {
|
||||
|
|
Loading…
Reference in a new issue