Chapter 11: Measuring the Spread of Our Data

Author

Zane Billings

Published

2024-07-28

options("scipen" = 9999, "digits" = 4)

This chapter defines the mean absolute deviation (MAD), variance, and standard deviation of a set of numbers.

Q1

One of the benefits of variance is that squaring the differences makes the penalties exponential. Give some examples of when this would be a useful property.

The exponential penalty of the variance can be useful when we expect all of our data points to be somewhat close together, so that outlying data points are penalized more severely the further away they are. If error is expensive, we also want to penalize errors increasingly as they become larger.

Q2

Calculate the mean, variance, and standard deviation for the following values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

vec <- 1:10
cat("Mean:    ", round(mean(vec), 3), "\n")
Mean:     5.5 
cat("MAD:     ", round(mad(vec, center = mean(vec)), 3), "\n")
MAD:      3.706 
cat("Variance:", round(var(vec), 3), "\n")
Variance: 9.167 
cat("SD:      ", round(sd(vec), 3), "\n")
SD:       3.028