jasperjiaguo commented on issue #9277: URL: https://github.com/apache/pinot/issues/9277#issuecomment-1396440724
NaN could be due to Math.sqrt(negative_number) or 0.0/0.0 We have recently discovered this impl of covariance/correlation has numerical stability issue when E[x^2] ~ E[x]^2 >> 0 (see [1](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Covariance) [2](https://github.com/trinodb/trino/blob/1866a23e3b0377144c1820de892c0de2762351a8/core/trino-main/src/main/java/io/trino/operator/aggregation/state/CorrelationState.java) [3](https://github.com/trinodb/trino/blob/1866a23e3b0377144c1820de892c0de2762351a8/core/trino-main/src/main/java/io/trino/operator/aggregation/state/CovarianceState.java)). Could we also use similar implementations? I'm not sure if the online algorithm is already available as a library, but feel free to use if apache common has it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org