diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2021-11-21 14:39:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-21 14:39:26 (GMT) |
commit | d2b55b07d2b503dcd3b5c0e2753efa835cff8e8f (patch) | |
tree | 91c10668dcb58309c6ac4a683075f00d38bdbb71 /Doc/library/statistics.rst | |
parent | 2afa1a12669e1812a9fe8130c8f60052c4ad8bf8 (diff) | |
download | cpython-d2b55b07d2b503dcd3b5c0e2753efa835cff8e8f.zip cpython-d2b55b07d2b503dcd3b5c0e2753efa835cff8e8f.tar.gz cpython-d2b55b07d2b503dcd3b5c0e2753efa835cff8e8f.tar.bz2 |
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>
Diffstat (limited to 'Doc/library/statistics.rst')
-rw-r--r-- | Doc/library/statistics.rst | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Doc/library/statistics.rst b/Doc/library/statistics.rst index bb03a2c..8638abf 100644 --- a/Doc/library/statistics.rst +++ b/Doc/library/statistics.rst @@ -643,7 +643,7 @@ However, for reading convenience, most of the examples show sorted sequences. .. versionadded:: 3.10 -.. function:: linear_regression(x, y, /) +.. function:: linear_regression(x, y, /, *, proportional=False) Return the slope and intercept of `simple linear regression <https://en.wikipedia.org/wiki/Simple_linear_regression>`_ @@ -677,8 +677,18 @@ However, for reading convenience, most of the examples show sorted sequences. >>> round(slope * 2019 + intercept) 16 + If *proportional* is true, the independent variable *x* and the + dependent variable *y* are assumed to be directly proportional. + The data is fit to a line passing through the origin. + Since the *intercept* will always be 0.0, the underlying linear + function simplifies to: + + *y = slope \* x + noise* + .. versionadded:: 3.10 + .. versionchanged:: 3.11 + Added support for *proportional*. Exceptions ---------- |