8000 Apply edits from Allen Downey's review of the linear_regression docs.… · python/cpython@b3f65e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit b3f65e8

Browse files
authored
Apply edits from Allen Downey's review of the linear_regression docs. (GH-26176)
1 parent fdc7e52 commit b3f65e8

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

Doc/library/statistics.rst

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -631,25 +631,25 @@ However, for reading convenience, most of the examples show sorted sequences.
631631
Return the intercept and slope of `simple linear regression
632632
<https://en.wikipedia.org/wiki/Simple_linear_regression>`_
633633
parameters estimated using ordinary least squares. Simple linear
634-
regression describes relationship between *regressor* and
635-
*dependent variable* in terms of linear function:
634+
regression describes the relationship between *regressor* and
635+
*dependent variable* in terms of this linear function:
636636

637637
*dependent_variable = intercept + slope \* regressor + noise*
638638

639639
where ``intercept`` and ``slope`` are the regression parameters that are
640-
estimated, and noise term is an unobserved random variable, for the
640+
estimated, and noise represents the
641641
variability of the data that was not explained by the linear regression
642-
(it is equal to the difference between prediction and the actual values
642+
(it is equal to the difference between predicted and actual values
643643
of dependent variable).
644644

645645
Both inputs must be of the same length (no less than two), and regressor
646-
needs not to be constant, otherwise :exc:`StatisticsError` is raised.
646+
needs not to be constant; otherwise :exc:`StatisticsError` is raised.
647647

648-
For example, if we took the data on the data on `release dates of the Monty
648+
For example, we can use the `release dates of the Monty
649649
Python films <https://en.wikipedia.org/wiki/Monty_Python#Films>`_, and used
650-
it to predict the cumulative number of Monty Python films produced, we could
651-
predict what would be the number of films they could have made till year
652-
2019, assuming that they kept the pace.
650+
it to predict the cumulative number of Monty Python films
651+
that would have been produced by 2019
652+
assuming that they kept the pace.
653653

654654
.. doctest::
655655

@@ -659,14 +659,6 @@ However, for reading convenience, most of the examples show sorted sequences.
659659
>>> round(intercept + slope * 2019)
660660
16
661661

662-
We could also use it to "predict" how many Monty Python films existed when
663-
Brian Cohen was born.
664-
665-
.. doctest::
666-
667-
>>> round(intercept + slope * 1)
668-
-610
669-
670662
.. versionadded:: 3.10
671663

672664

Lib/statistics.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -930,15 +930,15 @@ def linear_regression(regressor, dependent_variable, /):
930930
Return the intercept and slope of simple linear regression
931931
parameters estimated using ordinary least squares. Simple linear
932932
regression describes relationship between *regressor* and
933-
*dependent variable* in terms of linear function::
933+
*dependent variable* in terms of linear function:
934934
935935
dependent_variable = intercept + slope * regressor + noise
936936
937-
where ``intercept`` and ``slope`` are the regression parameters that are
938-
estimated, and noise term is an unobserved random variable, for the
939-
variability of the data that was not explained by the linear regression
940-
(it is equal to the difference between prediction and the actual values
941-
of dependent variable).
937+
where *intercept* and *slope* are the regression parameters that are
938+
estimated, and noise represents the variability of the data that was
939+
not explained by the linear regression (it is equal to the
940+
difference between predicted and actual values of dependent
941+
variable).
942942
943943
The parameters are returned as a named tuple.
944944

0 commit comments

Comments
 (0)
0