Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f2e703

Browse files
authored
bpo-44151: Various grammar, word order, and markup fixes (GH-26344)
1 parent 59acfd4 commit 2f2e703

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

Doc/library/statistics.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -643,38 +643,38 @@ However, for reading convenience, most of the examples show sorted sequences.
643643

644644
.. versionadded:: 3.10
645645

646-
.. function:: linear_regression(independent_variable, dependent_variable)
646+
.. function:: linear_regression(x, y, /)
647647

648648
Return the slope and intercept of `simple linear regression
649649
<https://en.wikipedia.org/wiki/Simple_linear_regression>`_
650650
parameters estimated using ordinary least squares. Simple linear
651651
regression describes the relationship between an independent variable *x* and
652652
a dependent variable *y* in terms of this linear function:
653653

654-
*y = intercept + slope \* x + noise*
654+
*y = slope \* x + intercept + noise*
655655

656656
where ``slope`` and ``intercept`` are the regression parameters that are
657-
estimated, and noise represents the
657+
estimated, and ``noise`` represents the
658658
variability of the data that was not explained by the linear regression
659659
(it is equal to the difference between predicted and actual values
660-
of dependent variable).
660+
of the dependent variable).
661661

662662
Both inputs must be of the same length (no less than two), and
663-
the independent variable *x* needs not to be constant;
664-
otherwise :exc:`StatisticsError` is raised.
663+
the independent variable *x* cannot be constant;
664+
otherwise a :exc:`StatisticsError` is raised.
665665

666666
For example, we can use the `release dates of the Monty
667-
Python films <https://en.wikipedia.org/wiki/Monty_Python#Films>`_, and used
668-
it to predict the cumulative number of Monty Python films
667+
Python films <https://en.wikipedia.org/wiki/Monty_Python#Films>`_
668+
to predict the cumulative number of Monty Python films
669669
that would have been produced by 2019
670-
assuming that they kept the pace.
670+
assuming that they had kept the pace.
671671

672672
.. doctest::
673673

674674
>>> year = [1971, 1975, 1979, 1982, 1983]
675675
>>> films_total = [1, 2, 3, 4, 5]
676676
>>> slope, intercept = linear_regression(year, films_total)
677-
>>> round(intercept + slope * 2019)
677+
>>> round(slope * 2019 + intercept)
678678
16
679679

680680
.. versionadded:: 3.10

Lib/statistics.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -936,26 +936,26 @@ def correlation(x, y, /):
936936

937937

938938
def linear_regression(x, y, /):
939-
"""Intercept and slope for simple linear regression
939+
"""Slope and intercept for simple linear regression.
940940
941-
Return the intercept and slope of simple linear regression
941+
Return the slope and intercept of simple linear regression
942942
parameters estimated using ordinary least squares. Simple linear
943-
regression describes relationship between *x* and
944-
*y* in terms of linear function:
943+
regression describes relationship between an independent variable
944+
*x* and a dependent variable *y* in terms of linear function:
945945
946-
y = intercept + slope * x + noise
946+
y = slope * x + intercept + noise
947947
948-
where *intercept* and *slope* are the regression parameters that are
948+
where *slope* and *intercept* are the regression parameters that are
949949
estimated, and noise represents the variability of the data that was
950950
not explained by the linear regression (it is equal to the
951-
difference between predicted and actual values of dependent
951+
difference between predicted and actual values of the dependent
952952
variable).
953953
954954
The parameters are returned as a named tuple.
955955
956956
>>> x = [1, 2, 3, 4, 5]
957957
>>> noise = NormalDist().samples(5, seed=42)
958-
>>> y = [2 + 3 * x[i] + noise[i] for i in range(5)]
958+
>>> y = [3 * x[i] + 2 + noise[i] for i in range(5)]
959959
>>> linear_regression(x, y) #doctest: +ELLIPSIS
960960
LinearRegression(slope=3.09078914170..., intercept=1.75684970486...)
961961

0 commit comments

Comments
 (0)