Illustration of Variance
For illustration, for the vector [4, 6, 1, 5], there are n = 4 values therefore n - 1 is 3. The mean of this data set is also 4. The variance will be
The built-in function to compute the variance is known as var:
>> shortx = [4 6 1 5];
>> myvar = var(shortx)
myvar =
4.6667