1. Learn
  2. /
  3. Courses
  4. /
  5. HarvardX Data Science Module 4 - Inference and Modeling

Exercise

Exercise 5. Standard deviation of the spread

The standard error is related to the typical size of the error we make when predicting. We say size because, as we just saw, the errors are centered around 0. In that sense, the typical error is 0. For mathematical reasons related to the central limit theorem, we actually use the standard deviation of errors rather than the average of the absolute values.

As we have discussed, the standard error is the square root of the average squared distance \((\bar{X} - p)^2\). The standard deviation is defined as the square root of the distance squared.

Calculate the standard deviation of the spread.

Instructions

100 XP
  • Use the sample code to generate errors, a vector of \(\mid p-\bar{X}\mid\).
  • Use ^2 to square the distances.
  • Calculate the average squared distance using the mean function.
  • Calculate the square root of these values using the sqrt function.