On this page
statistics.covariance
Prev: statistics.correlation | Up: statistics | Next: statistics.fmean
Rel: statistics.correlation, statistics.fmean, statistics.geometric_mean, statistics.harmonic_mean
Ref: docs.python.org — statistics.covariance
Tags: #public #python3 #stdlib #statistics
Import
import statistics
from statistics import covariance
Signature & Overview
statistics.covariance(x, y, /)
Covariance Return the sample covariance of two inputs x and y. Covariance is a measure of the joint variability of two inputs.
Usage
import statistics
if hasattr(statistics, 'covariance'):
assert statistics.covariance([1, 2, 3], [2, 4, 6]) == 2.0
Gotchas
- Requires Python 3.10+: Sample covariance ($n - 1$ denominator); requires at least 2 points.
REPL Inspect
from statistics import covariance
help(covariance)
Linked from
- tuts/python3/stdlib_module/statistics
- tuts/python3/stdlib_module/statistics/correlation
- tuts/python3/stdlib_module/statistics/fmean
- tuts/python3/stdlib_module/statistics/geometric_mean
- tuts/python3/stdlib_module/statistics/harmonic_mean
- tuts/python3/stdlib_module/statistics/kde
- tuts/python3/stdlib_module/statistics/kde_random
- tuts/python3/stdlib_module/statistics/linear_regression
- tuts/python3/stdlib_module/statistics/mean
- tuts/python3/stdlib_module/statistics/median
- tuts/python3/stdlib_module/statistics/median_grouped
- tuts/python3/stdlib_module/statistics/median_high
- tuts/python3/stdlib_module/statistics/median_low
- tuts/python3/stdlib_module/statistics/mode
- tuts/python3/stdlib_module/statistics/multimode
- tuts/python3/stdlib_module/statistics/NormalDist
- tuts/python3/stdlib_module/statistics/pstdev
- tuts/python3/stdlib_module/statistics/pvariance
- tuts/python3/stdlib_module/statistics/quantiles
- tuts/python3/stdlib_module/statistics/StatisticsError
- tuts/python3/stdlib_module/statistics/stdev
- tuts/python3/stdlib_module/statistics/variance
Related notes
- tuts/python3/stdlib_module/statistics/correlation Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/fmean Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/geometric_mean Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/harmonic_mean Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/statistics/kde links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/kde_random links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/linear_regression links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/mean links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/median links to this page; shared tags: #statistics, #stdlib