Question
Say that you want to measure something, say the length of a table. Denote by
the exact length of the table. Say now that you do a certain number of measures of the length of the table and get values
![{\displaystyle x_{1},x_{2},x_{3},\ldots x_{N-1},x_{N}}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/05f5a022fdac3239c94d764e552829dcd4947378)
where
is the number of measures you took. Now using all these measures, you want to construct an approximated value
which should give you a solid idea of how much the real measure
is. How to do so efficiently?
One very good idea would be to say that you want your value
to be the one that has the smallest sum of the square of the differences to all your measures. What does that mean, it means you want to compute
![{\displaystyle (x-x_{1})^{2}+(x-x_{2})^{2}+\ldots +(x-x_{N})^{2}}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/01c6836ccb47ab7c86b286bf9bb325839143ef14)
and you'll say that your best guess for
is the value
that makes the above as small as possible. Why that? Well it makes sense to look at all the differences
but since some might be positive and some negative, it makes sense to square them just to get them all positive and then to sum all that. Any number that makes the sum of the square differences small can be thought as being fairly in the middle and hence a really good guess for what all these measures are trying to get at.
Now the question is of course: great, how do I find that
guy if I'm given all these measures
?
Solution
|
Before reading the solution, you should really try the problem for yourself. By should I mean that if you don't you will not gain any understanding, whatever you might believe, this is 100% guaranteed. So do yourself a favour, try the problem and look at the solution once you've gave it an authentic try.
Solution
|
Well, let's just use optimization! So we assume that we are given the values and we're looking for the value that will minimize the sum of the square of the differences, in other words, we're looking for the minimum value of the function:
![{\displaystyle f(x)=(x-x_{1})^{2}+(x-x_{2})^{2}+\ldots +(x-x_{N})^{2}}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/df11b2a93b650c81d8a6e32eada59950369da202)
To do this, we'll start by finding its critical points. So we need first to compute its derivative.
![{\displaystyle f'(x)=2(x-x_{1})+2(x-x_{2})+\ldots +2(x-x_{N})}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/6d226970025ae4ce2202b59c22f3df9403e6efd1)
Then solve it for zero.
![{\displaystyle 2(x-x_{1})+2(x-x_{2})+\ldots +2(x-x_{N})=0\quad \iff \quad 2Nx=2x_{1}+2x_{2}+\ldots +2x_{N}}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/6ce3472d630ff85f021c948b168e5d762c18e71b)
and so
![{\displaystyle x={\frac {x_{1}+x_{2}+\ldots +x_{N}}{N}}}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/00f22bbacba7a4bb50d09d7eb5d97e50c14483a5)
Which is the only critical point and clearly a minimum since the second derivative of the function is
![{\displaystyle f''(x)=2N>0}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/cda75a8e6c6a8cf79a53eea593b5cf6861ece6c2)
which is always positive and hence concave up.
Looking more closely at our answer, we actually see that
![{\displaystyle x={\frac {x_{1}+x_{2}+\ldots +x_{N}}{N}}}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/00f22bbacba7a4bb50d09d7eb5d97e50c14483a5)
is the average of the values . So we've actually proved that the average of all the measures yields the value that minimizes the sum of the square of the difference of all the measures; a result that should have felt quite intuitive but for which we have a deeper understanding now.
|
|