# Dan's Segment 7

## To Calculate

1. We have our function $F(x) = x^2 - 2ax + a^2$ and we want to take its derivative w.r.t. a, so we get $f(x) = -2x + 2a = 0$ and the solution is clearly a=x.

3. Good: the first big positive about the median over the mean is that the median always exists whereas the mean does not for some distributions. The other big advantage is that the median is more resistant to outliers in many situations. For example, if you have a data set that looks like this: (0,1,0,2,3,0,1,1000) your mean is going to be way bigger than the likely center of the distribution, while the median will still reside close to the center.

Bad: The median assumes that the data is uniformly distributed and that you have sufficient data. Without a lot of data, the median can easily come far away from the actual population center. For instance, a data set (1,2,1,300,150) would have a mean of 2, which might not accurately reflect the real population.

1. One option is to fit a function to the data and then use that function to calculate the moments. I won't claim to have thought of this myself, but wikipedia tells me that the formula $\frac{1}{n}\sum_{i = 1}^{n} X^k_i\,\!$ will calculate moments with decent accuracy for large samples. I'm kind of surprised this works, but unfortunately wikipedia lists no source or derivation.