Link Search Menu Expand Document

Table of contents

  1. Variance
    1. Definition
    2. Formula to calculate the variance
  2. Code example
    1. How to calculate the variance in R
  3. References

Variance

Definition

The variance is a numerical value used to indicate how widely values in a data set vary. If individual observations vary greatly from the group mean, the variance is big; and vice versa.

The mean is therefore a measure of dispersion.

Formula to calculate the variance

\begin{equation} s^2 = \sqrt{ \frac{1}{n - 1} \displaystyle\sum_{i=1}^{n}{(x_i - \bar{x})^2} } \end{equation}

Code example

How to calculate the variance in R

# Create vector of numbers
x <- c(12, 7, 3, 4.2, 18, 2, 54, -21, 8, -5)

# Calculate and print variance
print(var(x))

References