Statistics Functions

statistics.covariance()

Measure joint linear variation of paired observations using the sample denominator n-1. Both sequences need equal lengths of at least two.

Formal Syntax & Structure

python syntaxpython
statistics.covariance(x, y, /)

Parameters & Attributes

NameTypeDescription
xsequence of real numbersPaired observations, same length as the other sequence.
ysequence of real numbersPaired observations, same length as the other sequence.

Return Value

float

Floating-point result; finite precision and domain restrictions apply.

Working Example

Example Snippetpython
import statisticsprint(statistics.covariance([1, 2, 3], [2, 4, 6]))
Python Reference