mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
GH-102670: Use sumprod() to simplify, speed up, and improve accuracy of statistics functions (GH-102649)
This commit is contained in:
parent
61479d4684
commit
457e4d1a51
3 changed files with 27 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
"""Test suite for statistics module, including helper NumericTestCase and
|
||||
x = """Test suite for statistics module, including helper NumericTestCase and
|
||||
approx_equal function.
|
||||
|
||||
"""
|
||||
|
@ -2610,6 +2610,16 @@ class TestLinearRegression(unittest.TestCase):
|
|||
self.assertAlmostEqual(slope, 20 + 1/150)
|
||||
self.assertEqual(intercept, 0.0)
|
||||
|
||||
def test_float_output(self):
|
||||
x = [Fraction(2, 3), Fraction(3, 4)]
|
||||
y = [Fraction(4, 5), Fraction(5, 6)]
|
||||
slope, intercept = statistics.linear_regression(x, y)
|
||||
self.assertTrue(isinstance(slope, float))
|
||||
self.assertTrue(isinstance(intercept, float))
|
||||
slope, intercept = statistics.linear_regression(x, y, proportional=True)
|
||||
self.assertTrue(isinstance(slope, float))
|
||||
self.assertTrue(isinstance(intercept, float))
|
||||
|
||||
class TestNormalDist:
|
||||
|
||||
# General note on precision: The pdf(), cdf(), and overlap() methods
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue