Moving Function linearWeightedAvg consistently under-reports value #113751
Labels
:Analytics/Aggregations
Aggregations
>bug
Team:Analytics
Meta label for analytical engine team (ESQL/Aggs/Geo)
Elasticsearch Version
8.15.2
Installed Plugins
No response
Java Version
bundled
OS Version
ubuntu 24.04
Problem Description
The
linearWeightedAvg
moving function appears to consistently return lower than expected values. Consider the below query where I calculate four moving averages - three of them look completely believable, butlinearWeightedAvg
is consistently low.Full repro below, but the first three results from it offer the raw values of:
We can calculate the mean of these to be exactly 15.5, and can agree that any moving function operating over these three values should return something between 15.4 and 15.7. Consider the below results:
The unweighted average matches our calculated mean perfectly.
ewma
andholt
fall within the expected range, butlinearWeighted
is well out of bands.Also worth noting from the below full results is that first two values of
linearWeighted
(before the window size of 3 can be satisfied) are much lower than expected -7.69921875
and11.548828125
.Lastly, and perhaps unrelated, but I would have expected the other two weighted averages to put more weight on the later data points, which being larger I would have thought would return a value higher than the mean in this case, not lower?
Full query and results below.
Query:
Results:
Steps to Reproduce
Run a query using
linearWeightedAvg
, observe the returned value is out of band.Logs (if relevant)
No response
The text was updated successfully, but these errors were encountered: