You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
statistics.pstdev and statistics.stdev round some exact Decimal ties to the odd neighbor #162645
With Decimal precision set to 2 and rounding set to ROUND_HALF_EVEN, pstdev and stdev both return 11 for an exact standard deviation of 11.5 and 13 for an exact standard deviation of 12.5. Both values should round to 12.
The last column gives an independent check. The population variance of [0, x] and the sample variance of [0, 0, 0, x] are both exactly x²/4, so both standard deviations equal x/2.
In _decimal_sqrt_of_frac, the correction compares the exact variance with the squared midpoint between the initial estimate and its neighbor. Both comparisons are strict. When the values are equal, the helper keeps the initial estimate even if its last digit is odd. The two rows above exercise opposite sides of that check.
The same discrepancy occurs at the default precision of 28 with x = Decimal(2 * 10**27 + 3).
Activity