4. Variance


The variance corresponds to the average of the squared differences from the mean.

Not sure to understand? Take any entry in your dataset, calculate the difference between its value and the mean and square it. Do the same for all the entries in the dataset. Eventually, calculate the average of these squared differences and you get the variance… easy!

In R, the function that calculates the variance is var():

my.dataset <- c(1,2,3,4,5,6,7,8,9,10)
var(my.dataset)

Skjermbilde 2016-05-20 22.33.09