lgingerich commented on issue #1545:
URL: https://github.com/apache/datafusion/issues/1545#issuecomment-4651036737

   I was taking a look into this and spent a bit of time on the algorithmic 
side of it to compare numerical accuracy of Welford+float, Welford+decimal, and 
sum-of-squares + decimal.
   
   TLDR is that it seems that Welford+float is always better than attempting to 
calculate the variance (and therefore std dev) natively for decimals due to how 
truncation/rounding error accumulates.
   
   Reference: 
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
   
   
   Here's a simple example of variance error accumulation for a set of random 
inputs:
   <img width="2401" height="1177" alt="Image" 
src="https://github.com/user-attachments/assets/41f67276-5e6d-498e-9e26-89dad5d36249";
 />
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to