Monday, July 02, 2007

Linear least square error estimation

Let z be some unknown function of x and y. Assume the function is close to linear, so we want a function
    f(x,y) = a x + b y + c
that approximates z by minimizing the total square error for a collection of N data points (xi, yi, zi). We will need to accumulate the following sums. This can be done incrementally in real time, if the data arrive that way. We can use exponentially weighted sums to give more importance to more recent data points, if that makes sense.
Sx = ∑ xi
Sy = ∑i yi
Sz = ∑i zi
Sxx = ∑i xi2
Syy = ∑i yi2
Sxy = ∑i xiyi
Syz = ∑i yizi
N = ∑i 1 (or with exponential weighting if desired)
Then we have a total square error:
    E = ∑i (zi - axi - byi -c)2
and we want to minimize that error by choosing (a,b,c) at a minimum:
    ∂E/∂a = ∂E/∂b = ∂E/∂c = 0

0 = Sxz - a Sxx - b Sxy - c Sx
0 = Syz - a Sxy - b Syy - c Sy
0 = Sz - a Sx - b Sy - cN
Then we can obtain (a,b,c) from linear algebra.
[ a ]    [ Sxx Sxy Sx ]-1  [ Sxz ]
[ b ] = [ Sxy Syy Sy ] [ Syz ]
[ c ] [ Sx Sxy N ] [ Sz ]
Based on all this, we can write a linear least-squares estimator class in Python.

Recent tech talk at Google: Aubrey de Grey

This is a Google Tech Talk by Aubrey de Grey, who has studied gerontology at Cambridge University. He has thought about ageing as a problem with an engineering solution. He has charted the course of the solution in broad strokes, and put together a credible plan to make good progress over the coming decades, with ideas about which science to pursue and how much money would be needed.

My health is good but not stellar and like many Americans, I'm overweight. I ordinarily assume that as my 50th birthday fast approaches, I've got 25 or 30 years left. That's how I try to plan my finances and other aspects of my life.

In this talk de Grey presents what he calls conservative estimates of what would be possible if we were to pursue his research program. If he's right, I've got a good shot at not just a few more decades of life, but perhaps a few more centuries, conceivably a lot more centuries.

I fear death as much as any normal person. Perhaps if I had more time, more youth, more energy, I could make some more important contribution to humanity than I've made. Certainly I have the selfish wish to have more freedom, travel more, make more money, play with more toys, read more books, have more sex, all that stuff.