]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-45876: Improve accuracy for stdev() and pstdev() in statistics (GH-29736)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Sat, 27 Nov 2021 05:54:50 +0000 (22:54 -0700)
committerGitHub <noreply@github.com>
Sat, 27 Nov 2021 05:54:50 +0000 (22:54 -0700)
commitaf9ee57b96cb872df6574e36027cc753417605f9
treef0cce757d3ce53ff64b31706875b3b8290f6f0ab
parentdb55f3fabafc046e4fca907210ced4ce16bf58d6
bpo-45876: Improve accuracy for stdev() and pstdev() in statistics (GH-29736)

* Inlined code from variance functions

* Added helper functions for the float square root of a fraction

* Call helper functions

* Add blurb

* Fix over-specified test

* Add a test for the _sqrt_frac() helper function

* Increase the tested range

* Add type hints to the internal function.

* Fix test for correct rounding

* Simplify ⌊√(n/m)⌋ calculation

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* Add comment and beef-up tests

* Test for zero denominator

* Add algorithmic references

* Add test for the _isqrt_frac_rto() helper function.

* Compute the 109 instead of hard-wiring it

* Stronger test for _isqrt_frac_rto()

* Bigger range

* Bigger range

* Replace float() call with int/int division to be parallel with the other code path.

* Factor out division. Update proof link. Remove internal type declaration

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Lib/statistics.py
Lib/test/test_statistics.py
Misc/NEWS.d/next/Library/2021-11-23-15-36-56.bpo-45876.NO8Yaj.rst [new file with mode: 0644]