The mean and squared differences#
This page assumes a lot more maths than the standard track of the course. In particular, it assumes that you know the basics of finding the derivative of a function.
In practice this means that, if you are in the US, you will need to have taken pre-calculus and calculus at school or university, and if you’re in the UK, that means you will need A-level maths. That said, the algebra and calculus you need here are basic enough that, if you are motivated, you could teach yourself what you need from web resources or an introductory textbook.
Nothing in the rest of the course assumes you can follow the mathematics in this page. The page is just for those of you who are interested, and do know that part of mathematics.
In the meaning of the mean we were studying prediction errors.
We imagined using the mean of a set of value as a predictor for those values. Then we looked at how far off we would be, on average, if we use the mean to predict each value.
Let’s say we have a sequence of
We often want to add up all the values, for example, when we calculate the
mean. I could write
We can write the mean using this notation. Use the symbol
The
Now we have the notation, we can return to our problem.
We are to going to take some value
This is the general formula for the specific plot we saw at the end of the
meaning of the mean page, where the value for
We want to find the value of
The plot turned out to be U-shaped; we want to find the horizontal axis
location (
We can find this location by transforming the formula in (1) above into a formula for the gradient of the line that (1) represents. This is taking the derivative. When the derivative of equation (1) is equal to zero, it means the gradient of (1) is 0, and this is true when we are at a peak or a trough of (1). We want the trough.
Let’s start by expanding out equation (1), and using the laws of sums to simplify the result:
Now differentiate with respect to
When equation (2) has value zero, we can be at a peak (the gradient is zero, but it’s about to become negative) or a trough (the gradient is zero, but it’s about to become positive).
Find the zero(s) for equation (2):
Equation (2) only has one zero, and it is when
We so far don’t know if this single zero is at a peak or a trough, but we can
differentiate equation (2) again, to see the slope of the slope.
If this is positive at
Therefore the mean