v.20.5Improvement

Fix negative results in variance calculations for varSamp and varPop

Ensure that varSamp, varPop cannot return negative results due to numerical errors and that stddevSamp, stddevPop cannot be calculated from negative variance. This fixes #10532. #10829 (alexey-milovidov).
Fixes numerical inaccuracies in varSamp and varPop to prevent negative variance results and disallows calculation of stddevSamp and stddevPop from negative variance values.

Why it matters

This feature addresses the issue where due to floating-point numerical errors, variance functions (varSamp, varPop) could return negative results, which are mathematically invalid. It also prevents standard deviation functions (stddevSamp, stddevPop) from being computed on negative variances, ensuring reliable and accurate statistical calculations.

How to use it

This fix is applied automatically in ClickHouse starting from the version containing this change—no action is needed from the user to enable it.