On this page
  1. statistics.linear_regression
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

statistics.linear_regression

Prev: statistics.kde_random | Up: statistics | Next: statistics.mean
Rel: statistics.correlation, statistics.covariance, statistics.fmean, statistics.geometric_mean
Ref: docs.python.org — statistics.linear_regression
Tags: #public #python3 #stdlib #statistics


Import

import statistics
from statistics import linear_regression

Signature & Overview

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

Slope and intercept for simple linear regression.

Usage

import statistics

if hasattr(statistics, 'linear_regression'):
    slope, intercept = statistics.linear_regression([1, 2, 3], [3, 5, 7])
    assert round(slope, 6) == 2.0 and round(intercept, 6) == 1.0

Gotchas

REPL Inspect

from statistics import linear_regression
help(linear_regression)

Linked from

Related notes