mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
bpo-45766: Add direct proportion option to linear_regression(). (#29490)
* bpo-45766: Add direct proportion option to linear_regression(). * Update 2021-11-09-09-18-06.bpo-45766.dvbcMf.rst * Use ellipsis to avoid round-off issues. * Update Misc/NEWS.d/next/Library/2021-11-09-09-18-06.bpo-45766.dvbcMf.rst Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> * Update signature in main docs * Fix missing comma Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
This commit is contained in:
parent
2afa1a1266
commit
d2b55b07d2
4 changed files with 42 additions and 8 deletions
|
@ -2527,6 +2527,12 @@ class TestLinearRegression(unittest.TestCase):
|
|||
self.assertAlmostEqual(intercept, true_intercept)
|
||||
self.assertAlmostEqual(slope, true_slope)
|
||||
|
||||
def test_proportional(self):
|
||||
x = [10, 20, 30, 40]
|
||||
y = [180, 398, 610, 799]
|
||||
slope, intercept = statistics.linear_regression(x, y, proportional=True)
|
||||
self.assertAlmostEqual(slope, 20 + 1/150)
|
||||
self.assertEqual(intercept, 0.0)
|
||||
|
||||
class TestNormalDist:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue