An R Introduction to Statistics

Variance

The variance is a numerical measure of how the data values is dispersed around the mean. In particular, the sample variance is defined as:

          n
s2 =--1--∑  (x - ¯x)2
    n - 1i=1  i

Similarly, the population variance is defined in terms of the population mean μ and population size N:

 2   1-∑N       2
σ  = N    (xi - μ)
       i=1

Problem

Find the variance of the eruption duration in the data set faithful.

Solution

We apply the var function to compute the variance of eruptions.

> duration = faithful$eruptions    # the eruption durations 
> var(duration)                    # apply the var function 
[1] 1.3027

Answer

The variance of the eruption duration is 1.3027.

Exercise

Find the variance of the eruption waiting periods in faithful.