Skip to main content
Statistics LibreTexts

6.2: Covariance

  • Page ID
    7231
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)

    Covariance is a simple measure of the way two variables move together, or “co-vary”. The covariance of two variables, XX and YY, can be expressed in population notation as:

    cov(X,Y)=E[(X−μx)(Y−μy)](6.2)(6.2)cov(X,Y)=E[(X−μx)(Y−μy)]

    Therefore, the covariance between XX and YY is simply the product of the variation of XX around its expected value, and the variation of YY around its expected value. The sample covariance is expressed as:

    cov(X,Y)=∑(X−¯X)(Y−¯Y)(n−1)(6.3)(6.3)cov(X,Y)=∑(X−X¯)(Y−Y¯)(n−1)

    Covariance can be positive, negative, or zero. If the covariance is positive both variables move in the same direction, meaning if XX increases YY increases or if XX decreases YY decreases. Negative covariance means that the variables move in opposite directions; if XX increases YY decreases. Finally, zero covariance indicates that there is no covariance between XX and YY.


    6.2: Covariance is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Jenkins-Smith et al. via source content that was edited to conform to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?