ID EN
Statistics

linear_regression

Python 3.11

Return the slope and intercept of simple linear regression parameters estimated using ordinary least squares. Simple linear regression describes the relationship between an independent variable x and a dependent variable y in terms of this linear function:

Syntax

PYTHON
statistics.linear_regression(x, y, /, *, proportional=False)

Examples

Example 1
PYTHON
>>> year = [1971, 1975, 1979, 1982, 1983]
>>> films_total = [1, 2, 3, 4, 5]
>>> slope, intercept = linear_regression(year, films_total)
>>> round(slope * 2019 + intercept)
16

See Also

StatisticsError